Support » Fixing WordPress » php Errors not Seen on my test system

  • error_reporting( E_ALL | E_STRICT );
    $array['def'] = 'def';
    foreach ( $array['abc'] as $a ) {

    On my test system, that PHP works “properly” and gives no error messages.

    A plugin user on different web hosting gets the following errors:
    Notice: Undefined index: abc in /home/inbikaco/public_html/_subdomains/demo1/foreach.php on line 4
    Warning: Invalid argument supplied for foreach() in /home/inbikaco/public_html/_subdomains/demo1/foreach.php on line 4

    I’ve now fixed my plugin, by adding an if ( isset( $array['abc'] )) in front of the foreach.

    My question is how to improve my Test environment so I catch errors like that? I routinely test with WP_DEBUG set to TRUE. And setting the PHP error reporting level clearly isn’t working either.

Viewing 3 replies - 1 through 3 (of 3 total)
  • PHP has the option to write errors to either the display (browser), log, or both. Have you tried checking your PHP log file in your development environment?

    Using <?php phpinfo(); ?> you can see find the location of your error log under error_log. Also check the values for log_errors and display_errors.

    These values are set in php.ini. Another simple test to see if this is the problem:

    <?php ini_set('display_errors', 'On'); ?>

    You are 100% correct. I had previously captured phpinfo() displays from both my test system and the plugin user’s system. He has display_errors ON and I have it OFF!

    I’ll also look more deeply into error_log as both local and master values are set to /var/log/php.log on my test system, but that file does not exist.

    Thank you for the help. Just what I needed.

    U need to define a value for it first, the system will run faster

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘php Errors not Seen on my test system’ is closed to new replies.