| <?php * * PHP page Execution Time Statistics class * * */class runtime { var $StartTime = 0; & nbsp; var $StopTime = 0; /Get Microsecond function get_microtime () { list ($usec, $sec) = explode (", Microtime ()); return (float) $usec + (float) $sec); &NBSP;&NBSP;&NBSP;&NBSP///Recording start Time function start () { $this->starttime = $this->get_microtime (); &NBSP;&NBSP;&NBSP;&NBSP}//Record end Time function stop () { $this->stoptime = $this->get_microtime (); &NBSP;&NBSP;&NBSP;&NBSP}//Calculation time spent & rounding function spent () { &nBsp; return round (($this->stoptime- $this->starttime) * 1000, 1); &NBSP;&NBSP;&NBSP;&NBSP} $runtime = new runtime (); //cycle times $count = 10000; $str = "string"; $str _single = ' This is a '; $str _double = "This is a"; $str _single_var = ' This is a '. $str; $str _double_var = "This is A$str"; echo ' <div style= ' display:none ' > '; //Print $count single quotes $runtime->start (); For ($i =0 $i < $count; $i + +) {echo $str _single;} $runtime->stop (); $SP _single = $runtime->spent (); //print $count double quotes $runtime->start (); For ($i =0 $i < $count; $i + +) {echo $str _double;} $runtime->stop (); $SP _double = $runtime->spent (); //print $count single quotes (mixed) $runtime->start (); For ($i =0 $i < $count; $i + +) {echo $str _single_var;} $runtime->stop (); $SP _single_var = $runtime->spent (); //print $count double quotation mark (mixed) $runtime->start (); For ($i =0 $i < $count; $i + +) {echo $str _double_var;} $runtime->stop (); $SP _double_var = $runtime->spent (); echo ' </div> '; echo ' circular output '. $count. ' Times, single quotes: '. $sp _single. ' Double quotes: '. $sp _double. ' Single quotation mark (mixed) When: '. $sp _single_var. ' Double quotes (mixed): '. $SP _double_var; ?> |
The test found that, in the case of no mixing, the advantage of single quotes is not obvious, and the single quotation mark efficiency is obviously better than double quotes.
Later in the following format: Echo ' <div style= ' display:none ' > '; Adherence to the standards of the consortium does not reduce efficiency.
Try opcodes with a rain check.
If selected, please help add the source: http://www.3oom.com/blog/16.html