note 99871 deleted from language.oop5.constants by danbrown

From: Date: Mon, 13 Sep 2010 21:41:20 +0000
Subject: note 99871 deleted from language.oop5.constants by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172529@lists.php.net to get a copy of this message
Note Submitter: matthijs at ischen dot nl ---- To John Galt: remember that eval is a costly operation ( eval is evil ) some alternatives: <?php $score = array(); $start = microtime( true ); explode( ';', 'A;B;C;D' ); $score['explode'] = microtime(true) - $start; $start = microtime(true); unserialize('a:4:{i:0;s:1:"A";i:1;s:1:"B";i:2;s:1:"C";i:3;s:1:"D";}'); $score['unserialize'] = microtime(true) - $start; $start = microtime(true); eval('return array("A", "B", "C", "D");'); $score['eval'] = microtime(true) - $start; print sprintf( "method %s is slowest\n", array_search( max( $score ), $score )); ?>

« previous php.notes (#172529) next »