Re: PHP code optimization

From: Date: Tue, 09 Jul 2002 23:39:53 +0000
Subject: Re: PHP code optimization
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-106630@lists.php.net to get a copy of this message
Peter Thoenen wrote:
Question on optimizing code for quicker runtimes. Which is quicker (this is on a webpage also..NOT commandline)? <?php if ($a){ echo 'abc'; } ?> OR <?php if ($a) { ?> abc <?php } ?>
Because the difference is going to be undetectable, this would probably be a question that only someone really familiar with the engine would be able to answer with any sort of assurance. My bet is that the second method is faster in theory, because switching in/out of PHP is likely marginally faster than executing the echo function. Maybe if you create some scripts that loop through these statements 10,000 times each and measure the time with microtime(), you can get a more affirmative answer and let the list know your results. Happy hacking. Chris

« previous php.general (#106630) next »