0
Can anyone explain me the proper use of '' and "" in php with difference??
<?php $a="hello"; $hello="hi"; echo $a; ?> why they used "hello" and 'hi'?? plz explain??
1 Answer
0
$i = 0;
echo '$i'; //output: $i
echo "$i"; //output: 0
as you can see, variables in single quotes are not changed with their value. Variables with double quotes, however, get replaced with their value when echoed.
But when you declare an variable, it doesn't matter, because PHP has weak dynamic type declaration, so anyways the given value will have a 'string' type.