View Single Post
Old 09-17-08, 03:26 PM   #31
plenty of work, no games
LovingSticky's Avatar
Join Date: Sep 2007
Posts: 559
Default Re: Learn PHP/MySQL Feedback Thread

Originally Posted by pross View Post
nice thread so far mate, i have only one small concern so far; you are using double quotes in your variables, tho this is ok to do and works fine it can lead to hassles later especially if you want to include a double quote in the html output, for example..

$test = "hello";
$output = "<a href="">" . $test;

the above snippet will break unless the double quotes inside the html link are escaped with a \

single quotes however do not have this problem..

$test = 'hello';
$output = '<a href="">' . $test;

Well, difference between single and double quotes is that double quotes get parsed, while single quotes do not. Ie. that if you do not need PHP to parse your strings, you should NOT use double quotes.

You should also not use [dot] to concat strings, much faster is to use comma, as it does not concat them, but just echoes them.

So, this is fastest:

echo '1', $itemid;

This is slower:

echo "1$itemid";

And this would be slowest:

echo "1".$itemid;

All those examples produce same result, of course.
Q9550@3.4 + Asus P5Q Premium + 16GB RAM + 2xVelociraptor 300GB + 4xWD Black 1TB RAID-5 on Adaptec 5805 + PoV GTX580 + Dell 3008WFP + Windows 7 x64
Xbox 360 Elite + Kinect + Onkyo receiver + Acoustic Energy Aelite 1/3/center speakers + 46" FullHD Samsung TV
LovingSticky is offline   Reply With Quote