PHP控件运算符(@)不起作用 [英] PHP control operator (@) doesn't work

查看:177
本文介绍了PHP控件运算符(@)不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

控制操作符用于使所有警告/错误保持沉默,无论后果如何.我想使用这个疯狂的工具,但是我想我有一些奇怪的服务器配置,而且-即使我在函数中添加@,它仍然会引发警告/错误:

The control operator is used to make all warnings/errors silent, no matter what the consequences are. I would like to use this crazy tool, but I guess I've got some strange server configuration and - even though I add @ to a function, it still throws warnings/errors:

$ php -a
Interactive shell

php > $f = @file('juzio');
PHP Warning:  file(juzio): failed to open stream: No such file or directory in php shell code on line 1
PHP Stack trace:
PHP   1. {main}() php shell code:0
PHP   2. file() php shell code:1

我一直在尝试找到对此负责的设置,但到目前为止没有发现任何问题.有人知道@为什么不为我工作吗?以防万一,我正在运行带有Suhosin-Patch的PHP 5.3.6-13ubuntu3.10.我还安装了xdebug(以防万一).

I've been trying to find a setting that is responsibe for this, but found nothing so far. Anybody knows why @ isn't working for me? Just in case, I'm running PHP 5.3.6-13ubuntu3.10 with Suhosin-Patch. I've got also xdebug installed (in case it matters).

请不要写关于error_reporting的内容.我的问题是关于@运算符.谢谢.

edit: please don't write about error_reporting. My question is about @ operator. Thanks.

推荐答案

php.ini配置文件中的scream.enabled指令将禁用错误抑制运算符(@)的作用:

The scream.enabled directive in your php.ini configuration file will disable the effects of error suppression operator (@):

引用手册:

scream扩展使您可以禁用沉默错误控制操作符,以便报告所有错误.此功能由ini设置控制.

The scream extension gives the possibility to disable the silencing error control operator so all errors are being reported. This feature is controlled by an ini setting.

请参见文档中的示例,以了解它如何影响错误.报告.

See the example from the documentation to understand how it affects error reporting.

禁用scream应该可以解决此问题.

Disabling scream should fix the issue.

在您的php.ini中更改指令,如下所示:

Change the directive in your php.ini, like so:

scream.enabled = 0

如果要在运行时禁用它,则可以按照手册中的说明使用ini_set:

If you want to disable it during run-time, then you can use ini_set as stated in the manual:

ini_set('scream.enabled', false);

这篇关于PHP控件运算符(@)不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆