WordPress.org

Ready to get started?Download WordPress

Forums

php Errors not Seen on my test system (3 posts)

  1. jonradio
    Member
    Posted 2 years ago #

    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.

  2. Paul Clark
    Member
    Posted 2 years ago #

    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'); ?>

  3. jonradio
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags