Troubleshooting common PHP issues

This guide will explain how to troubleshoot some more common issues with scripting in PHP. For customers using LCN Web hosting and WordPress hosting.

Turn on error reporting

If you’re having problems, one of the first things may want to do is enable error reporting. Error reporting takes a lot of the guess work out of debugging your code and should give you a good place to start. To turn on error reporting, include these lines of code at the top of your PHP script.


Please Note: Remember to turn off error reporting once you have fixed your issue. Leaving it enabled may show unwanted output to your visitors.

Broken Syntax

Often problems with PHP code are cause by something very simple. Check your syntax and look for broken code highlighting (if your editor supports it).

PHP code being displayed instead of running

If you’re code is being displayed on your website instead of running make sure all your files are saved with the .php extension. Another possible reason for this is that PHP is not enabled on your hosting. We don’t enable PHP on our Starter hosting package, so if you wish to run PHP and are using this package you will need to upgrade.

PHP version compatibility issues

With the arrival of PHP7 there are a few incompatibilities with older PHP versions as well as new features that aren’t backwards compatible. Before switching your website over to PHP7 we’d advise testing any PHP included in your site.

A list of backward incompatible changes from PHP 5.6.x to 5.7.x can be found here and a list of new features can be found here

You can change the version of PHP your web hosting uses from within your LCN account, which you can learn how to do by reading our handy guide.

PHP page loads continuously

If you’re using loops within your PHP code you may run into problems where by your script seems to never stop loading. A common cause of this problem is that the loop isn’t counting properly.

One way to debug this is to echo() the current count number at the beginning of each loop cycle, this will hopefully give you a better idea of where the problems lies.

If you’re not using loops and your page is continuously loading you should double check any HTML or Javascript code.

Advanced troubleshooting and PHP knowledge sharing

We highly recommend the very active discussion forum (PHP Builder) for discussing all aspects of PHP –

Was this article helpful?

Check out some of our related guides

Need a hand? Search over a hundred step-by-step support guides