Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

is there a way to view local PHP files in my browser without running Apache or anything? I'm using Snow Leopard.

share|improve this question
Do you want to see the native PHP code in your local browser or do you want to the rendered HTML equivalent? – ubiquibacon Jul 28 '10 at 21:54
Do you want to see the actual PHP code or you want to run the scripts and see the output (in a browser or CLI)? – Tom Jul 29 '10 at 11:32
Would you please accept my answer if it satisfies you or ask for more information if not??? Thanks. – Patkos Csaba Aug 6 '10 at 16:33

2 Answers 2

up vote 6 down vote accepted

A browser can not show you the output of a PHP file. This is because a PHP file needs to be run by an interpreter (the php interpreter). A browser has no means to do this, it just expect HTML code or in the best cases it will show you the content of .php file as a text.
However, there are a few ways you can see the output of a PHP file. You can run any PHP file from Terminal. cd into the folder where your php file is, and run it like this php ./my_file.php You will see the output in the Terminal window. The output will be the HTML code if your PHP generates HTML code. If this is the case, you can php ./my_file.php > output.html and open the output.html file in your browser.
Please note, there is no way you can interact with your PHP files. You have no way to fill in HTML forms and click HTML buttons.
These rules are general for all operating systems, not just MacOS.

share|improve this answer

If you don't want to argue with apache configuration (which is shipped with snowleopard), you can install MAMP(the free version) ! I've a very easy to use Apache + MySQL solution, that will allow you to run php pages locally.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.