Plugin Sale! Save 15% on pro plugins with discount code: FALL2020
Web Dev + WordPress + Security

WordPress Enable PHP Strict Error Reporting

When developing WordPress themes and plugins, I like to enable PHP’s strict error reporting. That way all errors and notices can be recognized and dealt with accordingly. Plus, enabling PHP strict error reporting is pretty easy to do using a simple must-use plugin. Here’s how to do it..

Enable strict error reporting

To enable PHP strict error reporting for your WordPress-powered site, create a blank PHP file named error-reporting.php (or whatever you wish), and then add the following code:

<?php 
/*
	Plugin Name: PHP - Strict Error Reporting
	Description: Enable strict error reporting for testing PHP.
*/
error_reporting(E_ALL | E_STRICT);

Then save the file and upload it to your site’s /wp-content/mu-plugins/ directory. If the directory does not exist, create it. So on the server you should have the following file:

/wp-content/mu-plugins/error-reporting.php

That’s all there is to it. Once uplaoded, this script instructs PHP to report all errors, even the strict ones. To see the script in action, simply enable WordPress debug mode. When debugging is disabled, the must-use plugin is safely ignored. It’s there when you need it :)

Also as a bonus here is a sweet online wizard for calculating PHP error_reporting codes. Super useful!

Jeff Starr
About the Author
Jeff Starr = Creative thinker. Passionate about free and open Web.
GA Pro: Add Google Analytics to WordPress like a pro.

2 responses to “WordPress Enable PHP Strict Error Reporting”

  1. phil salt 2015/09/09 2:04 pm

    Thanks Jeff for sharing this neat pocket error_reporting plugin. More power to the wp_debug. Be well

Comments are closed for this post. Something to add? Let me know.
Welcome
Perishable Press is operated by Jeff Starr, a professional web developer and book author with two decades of experience. Here you will find posts about web development, WordPress, security, and more »
Blackhole Pro: Trap bad bots in a virtual black hole.
Thoughts
Part of my success is from being able to look ahead down the road and see things coming before they actually get here.
Spent some time refreshing my business portfolio at MonzillaMedia.com :)
Tried lots of apps for making animated GIFs from screen captures, so far Kap is my favorite. For example the GIF on this post.
Autumn is my favorite time of year.
Stoked! Had a great interview with Eric over at Speckyboy.com :)
Air finally clearing here in WA. Feeling grateful to breathe again. #oxygenmatters
Past week here in WA state has been hellish. So much smoke, like living in a chimney.
Newsletter
Get news, updates, deals & tips via email.
Email kept private. Easy unsubscribe anytime.