Home  >  Article  >  Backend Development  >  php解释为何要用isset()

php解释为何要用isset()

WBOY
WBOYOriginal
2016-06-13 13:11:481125browse

php解释为什么要用isset()
在默认情况下PHP错误汇报等级不是最高
这就会出现一些小错误我们却看不到错误
根据实践发现PHP出现这些小错误会影响PHP大量执行速度,大量执行速度!
@压制错误,不代表就没有生成错误

开始

error_reporting(8191); #把错误汇报等级调到最高

echo $a;   #会出现错误 $a 没有事先定义

echo @$a; #什么也没有

最后对 isset 和 @ 进行速度测试 发现在 执行1000次后

isset 用时 0.0008±0.0001 秒
@ 用时 0.002 秒


还看不出道理就直接把 错误级别默认

if ( $a ) 循环1W次

if ( isset( $a ) ) 循环1W次

看看哪个速度快 快的不是一点

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