Home >Backend Development >PHP Tutorial >Comparison of if and or operating efficiency in PHP, phpifor efficiency_PHP tutorial

Comparison of if and or operating efficiency in PHP, phpifor efficiency_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:11:481133browse

Comparison of if and or operating efficiency in PHP, phpifor efficiency

The example in this article describes the comparison of the operating efficiency of if and or in PHP. Share it with everyone for your reference. The specific implementation method is as follows:

The operating efficiency of if and or is explained with examples. Interested friends can test it. The result of my test here is that or is more efficient than if. The specific code is as follows:

Copy code The code is as follows:
$t1 = microtime();
while($i<=10000){
If(!defined('APP_PATH')); // 0.011059
// defined('APP_PATH') OR 1; // 0.009398
$i++;
}

$t2 = microtime();
echo $t2 - $t1;
?>

Example 2:

Copy code The code is as follows:
$t1 = microtime();

while($i<=1000000){
If(!defined('APP_PATH')); //0.20043
// defined('APP_PATH') OR 1; //0.107475
$i++;
}

$t2 = microtime();
echo $t2 - $t1;
?>

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/926872.htmlTechArticleComparison of the operating efficiency of if and or in PHP, phpifor efficiency This article describes the comparison of the operating efficiency of if and or in PHP. Share it with everyone for your reference. The specific implementation method is as follows: Running if and or...
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