When a browser is pointed to a regular HTML file (a file with an .html or .htm extension), the Web server sends the file, as is, to the browser.
The browser processes the file and displays the Web page that is described by the HTML tags in the file. When a browser is pointed to a PHP file (a file with a .php extension), the Web server looks for PHP sections in the file and processes them, rather than just sending them as is to the browser. The steps the Web server uses to process a PHP file are as follows:
- The Web server starts scanning the file in HTML mode.
It assumes that the statements are HTML and sends them to the browser without any processing. - The Web server continues in HTML mode until it encounters a PHP opening tag (<?php).
- When the Web server encounters a PHP opening tag, it switches into PHP mode.
This is sometimes called escaping from HTML. The Web server assumes all subsequent statements are PHP statements and executes the PHP statements. If there is output, the server sends the output to the browser. - The Web server continues in PHP mode until it encounters a PHP closing tag (?>).
- When the Web server encounters a PHP closing tag, it returns to HTML mode. The scanning is then resumed, and the cycle continues from Step 1.
0 comments:
Post a Comment