Loading, please wait...

picture of me
Joe Rushton Fullstack Web Developer

The Performance Implications of PHP Warnings and Notices

21st March 2017 Reading Time: 2 mins
Tags: PHP

If you've ever worked with PHP, chances are you've forgotten to check if a variable or array key is set before referencing it and as a result you get an error that looks something like this:

PHP notice example

It's quite possible that your script still runs as expected and later down the line when it comes to deploying your project, you could just hide it with a core PHP method:

error_reporting(0);

No harm done, right? Wrong! Well in this case.. probably not, because a single notice won't do much harm. But when you have something looking like this

It definitely comes with some performance hits. Some performance testing was done with 10,000 notices and these are the stats:

The last and most important test was one done after fixing the notices: 19.51 ms.

 

Conclusion

Notices can easily go a miss but in the long term it's definitely good practice to stay on top of them. In most cases, a simple isset() or empty() check will do the trick.

Back to Homepage

Find me on social media