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.