Home  >  Article  >  php教程  >  PHP if和or哪个效率对比

PHP if和or哪个效率对比

WBOY
WBOYOriginal
2016-06-08 17:24:121119browse

本文章简单总结的一个PHP if和or哪个效率对比程序,大家可参考参考。

<script>ec(2);</script>

实例说明

 代码如下 复制代码

$t1 = microtime();
 
while($i     if(!defined('APP_PATH'));      // 0.011059
    // defined('APP_PATH') OR 1;   // 0.009398
    $i++;
}
 
$t2 = microtime();
echo $t2 - $t1;
?>

例2

 代码如下 复制代码

$t1 = microtime();
 
while($i     if(!defined('APP_PATH'));      //0.20043
    // defined('APP_PATH') OR 1;   //0.107475
    $i++;
}
 
$t2 = microtime();
echo $t2 - $t1;
?>

大家去测试一下吧这里我测试了的结果是or 比if效率要高一些哦。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn