When to use double quotes and single quotes in php ?
$var = "Sample Text !!";
echo '$var'; //Outputs $var
echo "$var"; //Outputs Sample Text!!
?>
Now does that mean we should use double quotes always ? NO !! You must be wondering why ? Well , it's obvious that double quotes will require some more overhead since it does processing , so it will take some more time than single quotes . If there is a single line to be printed or so then this is not an issue , but suppose you have a loop that iterates a million times , what then ? It will be that extra time multiplied by a million !!
Suppose you have something inside the loop which is as follows :-
echo "Item Number :- $item";
Then write it as :-
echo 'Item Number :-'.$item;
In case of larger iterations this method should work more quickly than the previous one !!
read more via WebDevFunda: When to use double quotes and single quotes in php ?.
Comments
When to use double quotes and single quotes in php ? — No Comments
HTML tags allowed in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>