PHP – Single vs. Double Quotes (Part 2)

April 5th, 2008 | by Avatar |

Single quotes are used to define a set of characters and double quotes for variables, and as said the two are not inter-changeable and PHP will not check for a variable within single quotes. Below is a faster way of doing the same script with the simple substitution of the double for the single quotes.

Example:
$myword = ‘PHP is Free’;
if ($myword == ‘PHP is Free’)
{
echo ‘Learn it Easy’;}

The changes might be very minimal but for a serious scripting author, speed is of the essence and slow web pages are quite annoying.  As a web user like you and me should know, the faster a page opens, the better and the more we like it.

Sorry, comments for this entry are closed at this time.