Billy's Blog

To post pictures and other goodies for free on the net.

My Photo
Name:
Location: Utah, United States

Born in Kapiolani Children's Medical Center, just a few blocks from Waikiki. Graduated from Kahuku High School. Rode BMX Freestyle for most of my life (more than 20 years), now my 8 year old son is ripping up the skate parks, but plans on getting drafted by the SeaHawks as a WR.

Thursday, December 13, 2012

Single quote vs Double quote in PHP

It is slightly faster to use single quotes.
This is because when you use double quotes PHP has to parse to check if there are variables in there.

So, if you do:
    $bar = 'world';
    $foo = "hello $bar";
    $baz = 'hello $bar';

$foo would contain "hello world" while $baz could contain "hello $bar"

Whenever you are not using variables inside a string it's good practice to just use single quotes so PHP doesn't have to parse the string.

--Paolo Bergantino from Stackoverflow.com