At times we get posting on the forum where user complain that when they are running a PHP file, the output is the file itself. This means that the script was not recognized as a PHP script and rather it was treated as plain text by the browser. There are two reasons why you can run into this situation to my knowledge.
If you are using short tags for writing PHP script like <? echo 'Hello World' ?>, you should ensure that you have short_open_tag INI directive set to '1' in your PHP INI file. If this is not the case the script will not be treated as PHP script. I would prefer PHP script like <?php echo 'Hello World' ?>. This is more clear and avoids confusion.
Another reason for running into this situation can be if the PHP file is not saved as ASCII/ANSI. Saving the PHP script in UNICODE/Multi-byte format will again fail the script to be recognized as PHP script. Always save the PHP script as plain text file to avoid running into this situation.
Hopefully this will help some of you in getting around this problem. Thanks for patient reading and good bye.