php中


我在某些函数前看到了code>@</code的用法,如下所示:

$fileHandle = @fopen($fileName, $writeAttributes);

这个符号的用途是什么?

它禁止错误消息 -
请参阅PHP中的错误控制操作符手册。

它可以抑制错误。

请参阅手册中的错误控制操作员

PHP supports one error control operator: the at sign (@). When prepended to
an expression in PHP, any error messages that might be generated by that
expression will be ignored.

>

If you have set a custom error handler function with
set_error_handler() then it will still get called, but this custom error handler can
(and should) call error_reporting() which will return 0 when the call that triggered the
error was preceded by an @…

未经作者同意,本文严禁转载,违者必究!