The Many Faces Of PHP
Given PHP’s origins, most people run PHP with the help of a web server. The latter serves static HTML files which your browser renders for viewing.
If the file contains PHP, the web server (assuming its PHP functionality is enabled) will do some magic, i.e. parse the PHP and send the resulting HTML back to the browser.
On your machine, creating an index.php file in the document root with the contents
then navigating to
produces something like
in the browser.
However, as of PHP 5, one can do the same thing using PHP’s built-in server
turns the current working directory into the document root and navigating to
returns something like
The third way is to run PHP without any server at all. Assuming you have the PHP interpreter installed and its path in the ‘path’ variable,
opens the PHP interactive shell. Then typing
returns