WordPress | Enable error handling
Production handling
- create theme's 404.php
- create theme's 500.php
htcaccess file or IIS CGI configuration error page location:
ErrorDocument 404 /index.php?error=404
ErrorDocument 500 /wp-content/themes/theme_name/500.php
- for IIS, we should make an additional configuration to avoid *.php pages not to show "No input file specified."
http://stackoverflow.com/questions/12387791/no-input-file-specified-php-error-under-iis
Development handling
Edit wp-config.php, and add:
#enable debug to view warnings and errors in pages
define("WP_DEBUG", true);
@ini_set("log_errors","On");
@ini_set("display_errors","On");
@ini_set("error_log","/full_path_to_windows_folder_from_hard_drive_root/phperrors.log");
#deactivate cron warnings
define('ALTERNATE_WP_CRON', true);
#PHP Warning: fopen failed to open stream: HTTP request failed! class-http.php on line 921
#$handle = fopen($url, 'r', false, $context);
Check if server variable exists without crashing the page
if(isset($_SERVER['REMOTE_ADDR']))
{
$userIP = $_SERVER['REMOTE_ADDR'];
}
Comments
Post a Comment