Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的项目的一个配置设置中,我在文件开头观察到以下两行:
@ini_set('memory_limit', '-1'); @set_time_limit(0);
我的疑问是上面两行代码和下面几行代码有什么区别?
ini_set('memory_limit', '-1'); set_time_limit(0);
在 PHP 中添加 @ 符号前缀的目的是什么?
请给我详细而中肯的答案。
提前致谢。
php 中的 @ 只是为了消除错误。
例如:
<?php $x = 5; $y = @$z;
所以 $y 将为空
如果你删除 @ 它会抛出一个错误。
错误控制运算符
PHP 支持一种错误控制运算符:at 符号 (@)。当附加到 PHP 中的表达式时,该表达式可能生成的任何错误消息都将被忽略。