Activating PHP Rendering

Because Mac OS X 10.3 and later comes with the command-line version of PHP out-of-the-box, you can use HyperEdit to run and display the results of your PHP code live. It is excellent for testing smaller amounts of code before insertion into a large site or testing non-complex pages. To activate PHP rendering, simply change the editing mode in the options palette to "PHP," and it will automatically be rendered. It can also be activated from the main menu via Preview:Editing Mode:PHP.

Change the mode to PHP in the options palette

The PHP editing mode can also be set for all new documents by selecting it in the content tab of HyperEdit's preferences.

Note: When HyperEdit is set to refresh instantly, it will report parse errors very often. Therefore setting a delay of 1 second is recommended.

The HTML source generated by PHP can be shown by pressing Command-Shift-Right Arrow, or by selecting the item from the Preview:PHP Output menu.


Why do DOCUMENT_ROOT, and other $_SERVER variables not work?

HyperEdit executes the PHP code through the command-line, and not Apache, therefore there is no server (and no server variables). These variables can be simulated manually in an include file if necessary.

PHP suddenly stopped working.

This is most likely the result of an infinite loop in your code. Correct the loop, then save the file, log out, and then log back in to fix the problem.

Note: Another good reason to set HyperEdit's refresh trigger on a delay or manually is because the PHP interpreter may get caught in an infinite loop while writing a loop. If this happens, log out and then back in.