PHP logo

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

echo php_sapi_name();

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

php -S localhost:8000 

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,

php --interactive

opens the PHP interactive shell. Then typing

echo php_sapi_name();