- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我保证,我知道最好不要忽略错误。运行 XML-Sitemaps 生成器会点击没有有效 session 信息的 URL 来取悦 CodeIgniter。结果是每个被抓取的页面都有一个 E_NOTICE 和一个让我疯狂的日志(和电子邮件通知)。没有任何问题,也没有人或机器人受到伤害——只有我的理智受到影响。
一些人已经为 CodeIgniter unserialize() 失败设计了修复程序:
我已经运行了每个前提,但仍然收到数百条以下通知:
NOTICE: unserialize() [<a href='function.unserialize'>function.unserialize</a>]: Error at offset 98 of 128 bytes
这让我回到原点,提出一个非常简单的问题。这是 CI 的 Session.php 中有问题的第 724 行:
$data = @unserialize(strip_slashes($data));
我没有添加抑制性的“@”——它已经存在了。这是否意味着它会在抛出时专门抑制 E_NOTICE 消息?如果不是,那条线怎么可能产生所有这些让我想把我的头发都扯掉的通知?
最佳答案
设置自定义错误处理程序会绕过 PHP 的错误处理 — 显然还有 PHP 的错误抑制:
It is important to remember that the standard PHP error handler is completely bypassed for the error types specified by error_types unless the callback function returns FALSE. error_reporting() settings will have no effect and your error handler will be called regardless - however you are still able to read the current value of error_reporting and act appropriately. Of particular note is that this value will be 0 if the statement that caused the error was prepended by the @ error-control operator.
<?php
set_error_handler(function ($errno, $errstr) {
echo $errstr;
}, E_ALL);
@unserialize("foo"); // Still shows $errstr!
这将接管 PHP,并且可能会忽略您的错误抑制设置。有可能 CodeIgniter 使用它自己的错误处理程序(我相信它有)并且不管错误抑制级别如何都吐出错误。
但是,PHP 似乎暗示检查错误报告级别并查看它是否等于零将告诉您错误是否应该被抑制。因此,理论上,您可以编辑 CodeIgniter 错误处理程序并添加一个 if (error_reporting()) {/* show error */}
。
关于php - 为什么 @ 运算符不会在 CodeIgniter 中抑制 E_NOTICE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12219351/
E_ALL ^ E_NOTICE 和 E_ALL & ~E_NOTICE 有什么区别? 据我了解,它们都排除了 E_NOTICE 级别的错误报告。但是在 PHP.ini 中使用了 &~ 形式,而我在很
我更喜欢在打开 E_NOTICES 的情况下进行开发,但是在处理数组索引时,我经常不得不编写过多的、过于冗长的代码。如何在启用 E_NOTICES 的情况下用更少的代码编写此代码。 禁止通知 if (
Looks like a lot of people did not understand the question, the notice I am getting is not about $fr
我尝试使用 laravel 在 mysql 中插入数据,但收到错误 ErrorException (E_NOTICE)试图获取非对象的属性,我不知道问题出在哪里,请帮助我。 我的 Controller
作为一名开发人员,我在打开 E_NOTICE 的情况下工作。不过最近有人问我为什么要修复 E_NOTICE 错误。我能想到的唯一原因是纠正这些问题是最佳实践。 还有其他人有任何理由证明花费额外的时间/
举例说明: 在Windows环境下:原本在php4.3.0中运行正常的程序,在4.3.1中为何多处报错,大体提示为:Notice:Undefined varialbe:变量名称.&nb
我应该在实时服务器上启用 E_NOTICE 吗? 正如我在 Why should I fix E_NOTICE errors? 中看到的那样 每个人都再次使用 isset()省略通知。我读过专业人士,
我正在编写自己的 var_dump 以满足某些可能只适用于我并且有问题的要求。 代码检查对象、数组等,最后进入一个阶段,它认为它留下了一个数字、一个字符串或一个 bool 值。 当然,一个字符串实际上
我有一个 PHP 脚本需要执行数小时,有时由于某些原因(例如执行需要连接到互联网的脚本时出现网络问题等),执行过程会停止一段时间后做了错误的事情(并且它总是导致 E_NOTICE 当进程走向错误的方向
我保证,我知道最好不要忽略错误。运行 XML-Sitemaps 生成器会点击没有有效 session 信息的 URL 来取悦 CodeIgniter。结果是每个被抓取的页面都有一个 E_NOTICE
通常 php 脚本在 E_NOTICE 之后继续运行,有没有办法在函数的上下文中将此提升为 fatal error ,也就是说我只需要在我的函数中通知退出而不是在核心 php 函数中退出,也就是说全局
我已经从 heroku 克隆了我的项目,并且正在使用 wampserver 和 composer 版本 2。有人可以帮助我理解为什么会出现此错误。 在 PackageManifest.php 第 13
我现在遇到的问题是很难找到真正的错误,因为发现了太多的 E_NOTICE。我们的服务器上有将近 600 个脚本复杂的站点,我为处理其中的大量站点做了很多工作,但仍然有很多。 每当错误百分比过高时,我都
首先我知道这个问题在这里不止一次出现过: Why should I fix E_NOTICE errors? Why should I fix E_NOTICE errors? Pros and co
这确实是一个非常简单的问题,我如何将 undefined variable 传递给函数而不会出现 E_NOTICE 错误? 当将 undefined variable 传递给诸如 isset() 之类
谁能解释一下 error_reporting(E_ALL); 和 error_reporting(E_ALL & ~E_NOTICE); 之间的区别? 我注意到,当我从 E_ALL 更改为 E_ALL
有哪些更好的方法可以避免应用程序逻辑中出现大量 isset(),并在需要时保留查看调试消息的能力 (E_NOTICE)? p> 首先假设:E_NOTICE 不是错误,而是用词不当,实际上应该是 E_D
对于 Symfony2 项目,我必须在博客文章和所谓的平台之间建立关系。平台根据您用于查看站点的域定义特定过滤器。例如:如果您通过 url first-example.com 加入该站点,该站点将仅提
我想使用 simpleTest 编写一个测试,如果我正在测试的方法导致 PHP E_NOTICE“undefined index : foo”,该测试将失败。 我尝试了 expectError() 和
我收到此错误:function split() deprecated list ($kk, $vv) = split( ' ', $buf, 2); 当我用 explode 或 preg_split
我是一名优秀的程序员,十分优秀!