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条)

报告相同问题?

悬赏问题

  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
  • ¥40 串口调试助手打开串口后,keil5的代码就停止了
  • ¥15 电脑最近经常蓝屏,求大家看看哪的问题
  • ¥60 高价有偿求java辅导。工程量较大,价格你定,联系确定辅导后将采纳你的答案。希望能给出完整详细代码,并能解释回答我关于代码的疑问疑问,代码要求如下,联系我会发文档