PJ droopy pants Posted November 19, 2009 Share Posted November 19, 2009 Which of these would be faster? echo '<tr><td align="center">Hey whats up</td></tr>'; or echo "<tr><td align='center'>Hey whats up</td></tr>"; Quote Link to comment https://forums.phpfreaks.com/topic/182114-single-qoute-double-qoute/ Share on other sites More sharing options...
Alex Posted November 19, 2009 Share Posted November 19, 2009 There's really no clear answer. Some people will argue for the single quotes, and some will suggest just the opposite. It also depends on your version of PHP. Either way there's no difference that you'll ever experience so it's really just up to user preference and convenience. For example, if you have a long string containing many double quotes it would be much easier to just use single quotes and avoid having to escape all the other double quotes. Quote Link to comment https://forums.phpfreaks.com/topic/182114-single-qoute-double-qoute/#findComment-960733 Share on other sites More sharing options...
PJ droopy pants Posted November 19, 2009 Author Share Posted November 19, 2009 ok thanks, I think i will run a loop test and echo that string about 10k times both ways and see if thre really is any difference. Though just maybe it was cut and dry. Quote Link to comment https://forums.phpfreaks.com/topic/182114-single-qoute-double-qoute/#findComment-960739 Share on other sites More sharing options...
PJ droopy pants Posted November 19, 2009 Author Share Posted November 19, 2009 looping 10k times there was no difference, I was surprised. Quote Link to comment https://forums.phpfreaks.com/topic/182114-single-qoute-double-qoute/#findComment-960762 Share on other sites More sharing options...
PJ droopy pants Posted November 19, 2009 Author Share Posted November 19, 2009 this is interesting though, while looping 10k times ?> <tr><td align="center">Hey whats up</td></tr> <? was almost 2 times as fast as echo '<tr><td align="center">Hey whats up</td></tr>'; ..I would have thought going in and out of php would have made it slower. Quote Link to comment https://forums.phpfreaks.com/topic/182114-single-qoute-double-qoute/#findComment-960773 Share on other sites More sharing options...
emopoops Posted November 19, 2009 Share Posted November 19, 2009 if theer was no diference why is there suddenly a way thats 2 times faster? are u making this up as u go? Quote Link to comment https://forums.phpfreaks.com/topic/182114-single-qoute-double-qoute/#findComment-960774 Share on other sites More sharing options...
PJ droopy pants Posted November 19, 2009 Author Share Posted November 19, 2009 dont take my word for it, try it for yourself <? function microtime_float(){$time = microtime();return (double)substr( $time, 11 ) + (double)substr( $time, 0, 8 );}microtime_float();$starttime=microtime_float(); $ft=10000; while($ft>0){ ?> <tr><td align="center">Hey whats up</td></tr> <? $ft=$ft-1; } $endtime=microtime_float(); $totaltime=round($endtime - $starttime,5); echo $totaltime; ?> vs <? function microtime_float(){$time = microtime();return (double)substr( $time, 11 ) + (double)substr( $time, 0, 8 );}microtime_float();$starttime=microtime_float(); $ft=10000; while($ft>0){ echo '<tr><td align="center">Hey whats up</td></tr>'; $ft=$ft-1; } $endtime=microtime_float(); $totaltime=round($endtime - $starttime,5); echo $totaltime; ?> Quote Link to comment https://forums.phpfreaks.com/topic/182114-single-qoute-double-qoute/#findComment-960781 Share on other sites More sharing options...
PJ droopy pants Posted November 19, 2009 Author Share Posted November 19, 2009 if theer was no diference why is there suddenly a way thats 2 times faster? are u making this up as u go? That's like saying "if you drive a bus 55 mph and you drive a car 55mph taking the same route they get there at the same time but if you take a train at 55mph in a straight line how can you suddenly get ther faster." is there somthign wrong with experimenting? Sorry for trying to find ways to do things faster. Yea I make stuff up just for fun. Quote Link to comment https://forums.phpfreaks.com/topic/182114-single-qoute-double-qoute/#findComment-960785 Share on other sites More sharing options...
emopoops Posted November 19, 2009 Share Posted November 19, 2009 htmlecho ' 'echo " "echo " \" " 0.150480.148530.149320.15578 0.153770.149220.147680.1665 0.151630.148390.147650.14975 0.151110.147960.147450.15073 0.149480.148940.149970.14948 lol i thot u meant the same thing i didnt see that it was different combination there hefty slthough now reading your comeback, i do stand by my question.. i mean its called 55 mph for a reason regardless of the vehicle. its a rate. they get there at the same time. Quote Link to comment https://forums.phpfreaks.com/topic/182114-single-qoute-double-qoute/#findComment-960788 Share on other sites More sharing options...
PJ droopy pants Posted November 19, 2009 Author Share Posted November 19, 2009 also i think eAccelerator is throwing off my results so im not really sure now. i get the same all 3 ways. dangit I thought I had something. Quote Link to comment https://forums.phpfreaks.com/topic/182114-single-qoute-double-qoute/#findComment-960789 Share on other sites More sharing options...
PJ droopy pants Posted November 19, 2009 Author Share Posted November 19, 2009 htmlecho ' 'echo " "echo " \" " 0.150480.148530.149320.15578 0.153770.149220.147680.1665 0.151630.148390.147650.14975 0.151110.147960.147450.15073 0.149480.148940.149970.14948 lol i thot u meant the same thing i didnt see that it was different combination there hefty slthough now reading your comeback, i do stand by my question.. i mean its called 55 mph for a reason regardless of the vehicle. its a rate. they get there at the same time. yes that is why i threw in the 3rd option of the train going a shorter route, the third option i was leaving php and rendering static html. Quote Link to comment https://forums.phpfreaks.com/topic/182114-single-qoute-double-qoute/#findComment-960790 Share on other sites More sharing options...
emopoops Posted November 19, 2009 Share Posted November 19, 2009 the ones that dont stop the php code or use the \ to whatever it does go slower i guess? "you would have thot......." yeah its that way fr mine. it must be because of acellorator whatever accelorator is whats your table look like? Quote Link to comment https://forums.phpfreaks.com/topic/182114-single-qoute-double-qoute/#findComment-960791 Share on other sites More sharing options...
PJ droopy pants Posted November 19, 2009 Author Share Posted November 19, 2009 the ones that dont stop the php code or use the \ to whatever it does go slower i guess? "you would have thot......." yeah its that way fr mine. it must be because of acellorator whatever accelorator is whats your table look like? eAccelerator is my best friend http://eaccelerator.net/ Quote Link to comment https://forums.phpfreaks.com/topic/182114-single-qoute-double-qoute/#findComment-960795 Share on other sites More sharing options...
emopoops Posted November 19, 2009 Share Posted November 19, 2009 is it fast or something? it seemed to mess times up for u! Quote Link to comment https://forums.phpfreaks.com/topic/182114-single-qoute-double-qoute/#findComment-960798 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.