JJohnsenDK Posted June 28, 2007 Share Posted June 28, 2007 Hey I just want to know if your script gets slower if i opening and closing php everytime i need php between html code. Like this: <div><?=$test['test'];?></div> And say that i do this about 20 times in one page of code. Would it then be slower than if i wrote all the html in php. Like this: <?php echo "<div>".$test['test']."</div>"; ?> Its propperly a simpel quesstion, but nice to know, right Quote Link to comment Share on other sites More sharing options...
per1os Posted June 28, 2007 Share Posted June 28, 2007 Doing it the latter is better, but as long as there is not 50,000 calls it shouldn't matter. Here is a way for you to test: <?php function microtime_float() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } $time_start = microtime_float(); $test['test'] = "test"; for ($i=0; $i<10000;$i++) { ?> <div><?=$test['test'];?></div> <?php } $time_end = microtime_float(); $time = $time_end - $time_start; echo "It took $time seconds to go in and out<br />\n"; $time_start = microtime_float(); $test['test'] = "test"; for ($i=0; $i<10000;$i++) { echo '<div>'. $test['test'] .'</div>'; } $time_end = microtime_float(); $time = $time_end - $time_start; echo "It took $time seconds to stay in<br />\n"; ?> Give that a try and see what the results are. As far as I am concerned I would prefer the echo statement and not go in and out. Just makes it easier to debug etc. Quote Link to comment Share on other sites More sharing options...
JJohnsenDK Posted June 28, 2007 Author Share Posted June 28, 2007 allright... thanks alot mate Quote Link to comment 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.