is there a way to view local PHP files in my browser without running Apache or anything? I'm using Snow Leopard.
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.
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.
If you only see code in a browser window with web sharing turned on, you may not have PHP turned on, and therefor need to edit httpd.conf located here: hard drive/private/ect/apache2/httpd.conf
It's hidden, but you can open with bbedit. Do a search for 'PHP'. Uncomment (remove hash from) the first instance you find to turn on PHP and save. The line looks like this:
LoadModule php5_module libexec/apache2/libphp5.so
Be sure to restart Apache as the last step (turning web sharing off and on again will do it)
To test that PHP is now working, create a PHP test file in your new user level web root (~/Sites) with the following command:
printf "<?php phpinfo(); ?>" > ~/Sites/phpinfo.php
to perform this in Terminal, use this guide: https://ole.michelsen.dk/blog/setup-local-web-server-apache-php-macos-x-mavericks.html