Zend Framework: Error Reporting is shut down regardless of ini File

i often run into a problem when variables/attributes have the wrong type. The Problem is that it is hard to trace since my PHP (5.3) just crashes, does not put out an error or even write to the error log (*1). It just crashes.

I think accessing a string like an array shouldn't be untraceable should it? I mean, PHP is not C right?

Is there a way to change this behavior or some sort of best practice to get around this problem? Apart from checking every variable everywhere all the time and therefore writing 5 times more code?

[Update] : Okay, if i simplify the code outside Zend it seems to work. It must be Zend related somehow. Though i do have all the phpSettings set in my application.ini:

phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
phpSettings.error_reporting = "E_ALL|E_STRICT"

And the code causing the Error (which works in a sandbox as i just tried) is this:

$prefix = (strpos($obj[3][1], 'videometa') !== false) ? "http://www7.example.org" : "http://www.example.org";

Where $obj is a json string.

[Update 2] : So i tried echoing the php setting using ini_get right above my code and it says error_reporting is on E_ALL|E_STRICT, display_error is ON etc.

So this:

echo '<br/>ini_get = '.ini_get('display_errors').';';
echo '<br/>ini_get = '.ini_get('error_reporting').';';
echo '<br/>ini_get = '.ini_get('error_log').';';
echo '<br>$obj: ';
$obj = 'peter';
var_dump($obj);

echo '<br/>Now for the critical code:';
$prefix = (strpos($obj[MC_IMAGETYPE_VDT][1], 'videometa') !== false) ? "http://www7.example.org" : "http://www.example.org";

echo '<br/>It never shows this!';

Puts out this:

ini_get = 1;
ini_get = E_ALL|E_STRICT;
ini_get = /Applications/MAMP/logs/php_error.log;
$obj: string(5) "peter"

Now for the critical code:

And then stops. Any Ideas?

*1. php.ini has display_errors = On and error_reporting = E_ALL and so on. All good.


I don't think the method you are using to set error reporting is correct, you are setting it to a string value when it should be numeric (or a constant such as E_ALL which has a numeric value). Try just:

phpSettings.error_reporting = E_ALL|E_STRICT

(ie no quotes) or:

phpSettings.error_reporting = 32767

If all else fails you could always temporarily set the error reporting value above the code that you think is causing the problem:

error_reporting(E_ALL);

also, you have:

$prefix = (strpos($obj[MC_IMAGETYPE_VDT][1], 'videometa') !== false) ? "http://www7.example.org" : "http://www.example.org";

but $obj is a string which you are trying to access as a nested array. This will give you Fatal error: Cannot use string offset as an array which is probably why your code is failing.

链接地址: http://www.djcxy.com/p/58908.html

上一篇: PHP脚本呼应部分的PHP而不是什么意图

下一篇: Zend Framework:无论ini文件如何,都会关闭错误报告