diff --git a/features/commandline.xml b/features/commandline.xml index f004286fbb..72c59c0a72 100644 --- a/features/commandline.xml +++ b/features/commandline.xml @@ -1589,57 +1589,103 @@ php > be used in production. + + URI requests are served from the current working directory where + PHP was started, unless the -t option is used to specify an + explicit document root. + + + + If a URI request does not specify a file, then either index.html + or index.php in the given directory are returned. If neither file + exists, then a 404 response code is returned. + + + + If a PHP file is given on the command line when the web server is + started it is treated as a "router" script for the web server. + The script is run at the start of each HTTP request. If this + script returns false, then the requested resource is returned + as-is. Otherwise the script's output is returned to the browser. + + - Loading a file + Starting the web server - &example.outputs; + + The terminal will show: + + + + After URI requests for http://localhost:8000/ and + http://localhost:8000/myscript.html the terminal will show + something similar to: + + + - Loading a directory + Starting with a specific document root directory - &example.outputs; + + The terminal will show: + - Example output while making HTTP requests + Using a Router Script + + Requests for images will display them, but requests for HTML files will display "Welcome to PHP" + -]]> +// router.php +if (preg_match('/\.(?:png|jpg|jpeg|gif)$/', $_SERVER["REQUEST_URI"])) + return false; // serve the requested resource as-is. +else { + echo "

Welcome to PHP

"; +} +?>]]>
- &example.outputs.similar; + + After several URI requests the terminal will show something similar to: +