note 82639 deleted from control-structures.elseif by nlopess

From: Date: Sat, 19 Apr 2008 23:11:59 +0000
Subject: note 82639 deleted from control-structures.elseif by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-138544@lists.php.net to get a copy of this message
Note Submitter: jouimet at uwaterloo dot BLOCK_IT dot ca ---- Based on a test averaged over one hundred attempts (whereby one billion iterations occured during each attempt) on the alternative "else if" and "elseif" methods, I have observed that the "elseif" method completes its task more than 99% faster than the "else if" method. This test was completed on a MacBook Pro with Mac OS 10.4.11 running an Apache server with PHP 5.2.3. The conditional statements used within the iterations were the following (with $x = 10): <?php if ($x = 0) { $res = 'f'; } else if ($x = 1 || $x = 2 || $x = 3 || $x = 4 || $x = 5 || $x = 6 || $x = 7 || $x = 8 || $x = 9 || $x = 10) { $res = 'v'; } ?> <?php if ($x = 0) { $res = 'f'; } elseif ($x = 1 || $x = 2 || $x = 3 || $x = 4 || $x = 5 || $x = 6 || $x = 7 || $x = 8 || $x = 9 || $x = 10) { $res = 'v'; } ?>

« previous php.notes (#138544) next »