The following steps describe the request-response sequence for a PHP file:
1. The Web browser requests a document with a .php extension.
2. The Web server sends the request on to the PHP parser, which is either built into the Web server binary or exists separately as a filter or CGI executable.
3. The PHP parser scans the requested file for PHP code.
4. When the PHP parser finds PHP code, it executes that code and places the resulting output (if any) into the place in the file formerly occupied by the code.
5. This new output file is sent back to the Web server.
6. The Web server sends the output file along to the Web browser.
7. The Web browser displays the output.