CodeIgniter Forums
What is faster? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: What is faster? (/showthread.php?tid=9515)



What is faster? - El Forum - 06-27-2008

[eluser]SeanJA[/eluser]
I have always been curious, which way is faster?

Code:
<td> &lt;input size='25' name='department' value='&lt;?php echo $user-&gt;department ?&gt;'  /> </td>

or

Code:
&lt;?php echo "<td> &lt;input size='25' name='department' value='",$user-&gt;department,"  /> </td>"; ?&gt;

I generally use the first way, but working in a group there is a lot of code that ends up looking like the second one...


What is faster? - El Forum - 06-27-2008

[eluser]parrots[/eluser]
I would assume the first is faster. Where you really start to notice a speed difference in where you're having lots of opening and closing of PHP blocks near each other -- in that case you'd want one PHP block with multiple echos (or one long one if applicable).


What is faster? - El Forum - 06-27-2008

[eluser]EEssam[/eluser]
[quote author="parrots" date="1214620861"]Where you really start to notice a speed difference in where you're having lots of opening and closing of PHP blocks near each other[/quote]

I guess the difference is a few milliseconds, right?


What is faster? - El Forum - 06-27-2008

[eluser]parrots[/eluser]
Right, but it can add up quickly if you're getting lots of hits and you do it a lot. It's not a huge performance hit, but every little bit adds up.