3
05/11/2024 12:36 pm
Topic starter
I am newbie to PHP..
Just want to ask: in PHP what is the difference between single ('example') and double quotes ("example")?
1 Answer
3
05/11/2024 12:37 pm
SINGLE QUOTES:
When you put something in single quotes - even variable - it will ALWAYS be STRING;
Example:
<?php echo 'Enter your grade:'; $grade = 4; $oldGrade = 5; $finalGrade = ($grade + $oldGrade) / 2; var_dump($finalGrade); echo 'dasdsadadasd$finalGrade';
Output:
DOUBLE QUOTES:
In double quotes it WON'T BE ALWAYS STRING! If you add variable - it will show the variable.
Example:
<?php echo 'Enter your grade:'; $grade = 4; $oldGrade = 5; $finalGrade = ($grade + $oldGrade) / 2; var_dump($finalGrade); echo "dasdsadadasd$finalGrade";
Output:
Great! Thank you! Very useful!