View Single Post
Old 08-27-08, 02:17 PM   #26
Ngemu Mod
Join Date: Jul 2003
Location: Fresno, CA
Posts: 1,886
Default Re: Learn PHP/MySQL Feedback Thread

Originally Posted by ViN86 View Post
i typically use double quotes and escape them when i want them in the HTML. but single quotes would probably be a better idea.
Double quotes allows you to insert php variables directly in the string without concatenation. Ie.

$var = 'text';
echo "<input type='$var' />";
The php documentation seems to indicate that single quote strings are faster to parse though since the interpreter doesn't need to scan the string for php variables. You can also use double quotes for the php string and use single quotes for the html like above.

The primary issue with using either single or double quotes with HTML within a string is when it comes to javascript function calls and their arguments when the arguments are javascript strings. In which case, either concatenation or quote escapes will work.
[i7 2600k @4.4ghertz][2x4 GB DDR3 1600][EVGA GTX570 1.280GB SC][EVGA GTX460 physx][Asrock Extreme7 Gen3 Z68][2xSeagate 160 Gb SATA HD raid0][Seagate 250 GB SATA2 HD][Sony Bravia 40' 1080p LCD HDTV][NEC 3520a DVD+-DLw][Windows 7 Ultimate x64][Rosewill 1000w]
fivefeet8 is offline   Reply With Quote