How to Fix PHP Source Code Being Displayed in Browser

Submitted by: 
Visitors have accessed this post 470 times.

Fix PHP Source Code Being Displayed in Browser

If you are looking for this solution then you are at the right place. If the PHP source code is being displayed on your web browser, well it means that the server it's not already setup to serve or to run the PHP scripts or source code in the browser. These are the things to be done in order to debug the issue in displaying PHP source code in your browser.

Here's the list of things that you need to check to debug the issue on your web server.

PHP Installed

Are you sure that the PHP actually installed to the web server? Most of the servers will only serve HTML files and this is the default for the servers. This is one of the steps to fix the issue in displaying the PHP source code in Web Browser. You must to install the PHP and configure it to work on your web server. Make sure that the PHP was installed properly. In youtube, you will find more video tutorials on how to installed or to setup PHP to your Web Server to work on Linux, Windows, and Macintosh.

Misconfigure

If the PHP already installed to your Web Server but still the PHP source code being displayed on the web browser, then you have a misconfiguration when you installing the PHP on the Web Server. This bug is easy to fix it, this can be solved by uncommenting the line in a configuration line. You will need to make sure that the line has been uncommented and you must check at the beginning of the line that there is no semi-colon (";").

Restart the Web Server

If you already installed the PHP in your Web Server or you have set everything even the configuration of PHP is ok but still the PHP source code displaying to your web browser then you should do this thing is to restart your Web Server. You will need to restart it for the changes to take the effect.

.php Extension

If you have done all the steps above and the PHP source code is still being displayed on your browser, then you will need to check or to make sure that all your files are end with the .php extension. The PHP source code will not be executed if the extension is .html, you must double check all your file end with .php.

Run using Web Server

For the last steps to fix the bug, you will need to do is to make sure always that you are actually used the Web Server to run your PHP file. Most of the beginner they will open their file through their file system also, instead to use the PHP Web Server. HTML can be done via file system to open or to run it but in the PHP it will not work it.

Those are the steps to fix PHP source code being displayed in a browser. Hope you will find helpful this simple tutorial.


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.