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.
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.
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 (";").
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.
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.
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.