Talking about the single double quotation mark of PHP

Source: Internet
Author: User

<?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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.