PHP 基准测试 - 检查未设置的变量或警告关闭
有谁知道优点缺点,例如检查变量是否设置的速度而不是简单地关闭警告?
下面是一个非常糟糕的例子,但说明了我的意思:
#Does a check for the variable - error reporting on (Display no warnings)
$i = (!isset($i)) ? $i + 5 : 5;
#error reporting off (Display no warnings)
$i = $i + 5;
提前感谢您的任何想法!
Does anyone know of the advantages disadvantages e.g. speed for checking to see if a variable is set rather than simply turning off warnings?
below is very bad example but illustrates what I mean:
#Does a check for the variable - error reporting on (Display no warnings)
$i = (!isset($i)) ? $i + 5 : 5;
#error reporting off (Display no warnings)
$i = $i + 5;
Thanks in advance for any thoughts!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这归结为一个基本问题:应用程序正确运行还是快速运行更重要?
如果您只是忽略警告,则可能会忽略逻辑错误。您的程序可能执行得很快,但最快的错误应用程序的价值比最慢的功能应用程序的价值要小。
This boils down to a fundamental issue: is it more important for your application to run correctly, or to run quickly?
If you simply ignore warnings, logical errors may be overlooked. Your program may execute quickly, but the fastest faulty application has less value than the slowest functional one.