douliao2493 2014-01-10 13:14
浏览 59
已采纳

@ -sign在Ubuntu 12,php5和xdebug中

I develop in Vagrant VM with Ubuntu 12.04 and php 5.5.7. and faced problem of incorrect error reporting handling in this case: @-sign works incorrectly.

When using custom error handlers and globally turned on error reporting, @-calls (such as @unlink('...')) should trigger custom handler but calling error_reporting() from it should return 0 in this case:

http://ca3.php.net/manual/en/language.operators.errorcontrol.php

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 @.

But in fact it returns -1!

Googling have not resulted in anything.

Have anyone any idea, how to make it work correctly? And what can cause this?

UPD

The question is not about using or not using of @-sign. Even if I don't use it, vendors of third-party packages use it. And don't tell me that this packages are bad because of it, you will be wrong. In some situations, when using @ wisely, it can fix issues caused by bad design of old native php functions that produce warnings in places where they should not. But this is a hollywar and doesn't matter in question context.

The question is about making it work correctly in given environment and localization of issue source

UPD2

Problem was found, see accepted answer

  • 写回答

2条回答 默认 最新

  • douhuijun3776 2014-01-14 19:44
    关注

    Well, I've found the problem... Xdebug is installed, and the problem is there.

    Xdebug docs say:

    xdebug.scream

    Type: boolean, Default value: 0, Introduced in Xdebug >= 2.1

    If this setting is 1, then Xdebug will disable the @ (shut-up) operator so that notices, warnings and errors are no longer hidden.

    But by some reason, after installing it via apt-get install -y php5-xdebug it sets scream to 1 in /etc/php5/mods-available/xdebug.ini

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?