再谈PHP单双引号问题
Jun 21, 2016 am 08:51 AM
/* * php 页面执行时间统计类 * */ class runtime { var $StartTime = 0; var $StopTime = 0;
//获取微秒 function get_microtime() { list($usec, $sec) = explode(' ', microtime()); return ((float)$usec + (float)$sec); } //记录开始时间 function start() { $this->StartTime = $this->get_microtime(); } //记录结束时间 function stop() { $this->StopTime = $this->get_microtime(); } //计算所用时间&取整 function spent() { return round(($this->StopTime - $this->StartTime) * 1000, 1); } }
$runtime = new runtime();
//循环次数 $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 ' ';
echo '循环输出'.$count.'次,单引号用时:'.$sp_single.' 双引号用时: '.$sp_double.' 单引号(混合)用时:'.$sp_single_var.' 双引号(混合)用时:'.$sp_double_var;
?> |
经测试发现,不混合的情况下,单引号的优势并不明显,混合时单引号效率明显优于双引号。
以后用以下格式: echo '

인기 기사

인기 기사

뜨거운 기사 태그

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











Windows 11에서 창 테두리 설정을 조정하는 방법: 색상 및 크기 변경

Windows 11에서 제목 표시줄 색상을 변경하는 방법은 무엇입니까?

Windows 11에서 작업 표시줄 축소판 미리 보기를 활성화 또는 비활성화하는 방법
