How to Work with PHP programs on Mac OS X
The Mac OS X operating system comes pre-installed with the libraries needed to run PHP programs. You can
interact with PHP programs via the Terminal application (Applications -> Utilities -> Terminal). You can also
use the built-in web server that comes with Mac OS X, the Apache web server, to execute PHP programs. For
more information on running PHP via the local web server, see the following:
Running PHP on Apache for Mac
PHP programs can be created using any text editor such as EditRocket. PHP programs and scripts typically end with the .php extension. EditRocket will automatically recognize files with the .php extension as PHP programs, and will color the syntax accordingly.
To create a PHP program, simply create a new file, such as hello.php. In the file, place the following:
<?php echo "Hello, world!"; ?>
The above program can be executed using the EditRocket Tools -> PHP -> Execute Program option,
or you can execute it from the Terminal window. To execute the script in the Terminal, use
the cd command to cd to the directory where the hello.php file was saved, such as
Then type the following:
Hello World! should then be printed to the screen.