PHP Tip – Use Single Quotes when Possible

By using single quotes instead of double quotes, you save PHP from having to parse your string for variables. It not only is faster, but I find it is more programmer friendly since it is easier to find variables in your code.

Also, when referencing an array that has a string index, always use single quotes. This prevents PHP from having to figure out exactly what you were trying to say.

$var = 'Hello World'; 


$var = "Hello World"; 

Leave a Reply

Your email address will not be published. Required fields are marked *