I'm writing a wordpress widget plugin. It should output some html code which should look like this
<a href="link1">link1title</a>
<a href="link2">link2title</a>
<a href="link3">link3title</a>
<a href="link4">link4title</a>
<a href="link5">link5title</a>
I'm running a for loop to output the links and titles from 2 arrays, and I can do that in two different ways:
<?php for ($i = 0; $i < $x; $i++)
echo '<a href="'.$links[$i].'">'.$titles[$i].'</a>';
?>
Or I can use something like this:
<?php ob_start();
for ($i = 0; $i < $x; $i++) {?>
<a href="<?php echo $links[$i];?>"><?php echo $titles[$i];?></a>
<?php ob_get_flush();?>
The example is trivial. There is a lot more html code, and a lot more variables involved. Since there is a speed difference between printf and cout in c/c++, I was wondering is there a speed difference between using output buffer and echo.
Also, which one is better to use?