Home  >  Article  >  Backend Development  >  PHP初记(1) - @函数名的作用

PHP初记(1) - @函数名的作用

WBOY
WBOYOriginal
2016-06-13 11:01:37828browse

PHP小记(1) - @函数名的作用

PHP中调用函数(我个人觉得用“函数”比用“方法”要适合些)的时候,在函数名前面加@,那么当执行函数出错时,不会显示出错信息


例如:

function foo($n) {    $result = 1/$n;    return $result;}echo @foo(0); // 函数中会产生除 0 错误,但加上 @ 后并不显示该错误。echo "end"; // 继续输出 end

注意仔细看代码中的注释就会完全明白了。

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