PHP software works with the web server, the software that delivers web pages to the world. When you type a URL in the address bar of your web browser, you send a message asking it to send an HTML file to the webserver at that URL. The web server responds by sending the requested file. Your browser reads the HTML file and displays the web page.
When you click a link on the web page, you also want a file from the webserver. Also, when you click a web page button submitting a form, the webserver processes a file. When PHP is installed, this process is actually the same. You want a file, the webserver runs PHP and sends HTML back to the browser, thanks to programming in PHP.
More specifically, when PHP is installed, the webserver is configured to expect certain file extensions to contain PHP language expressions. Usually the extension is .php or .phtml, but any extension can be used. When the webserver receives a request for a file with the specified extension, it sends HTML statements as-is, but PHP statements are processed by PHP software before it is sent to the client.
When PHP language expressions are processed, only the output or anything printed on the screen is sent to the web browser by the webserver. Since PHP language expressions that do not produce output to the screen are not included in the output sent to the browser, PHP code is not normally seen by the user.
For instance, in this simple PHP statement, <?php is the PHP opening tag, and ?> is the closing tag.
<?php echo "<p>Hello World</p>"; ?>
Here, echo is a PHP instruction that tells PHP to output the upcoming text. The PHP software processes the PHP statement and outputs the following:
<p>Hello World</p>
This regular HTML expression is sent to the user’s browser. The browser interprets the expression as HTML code and displays a web page with a paragraph – Hello World. Since the PHP statement is not delivered to the browser, the user never sees a PHP statement. PHP and web server should work closely together.
PHP is not integrated with all web servers, but it works with many popular web servers. PHP works well with the Apache webserver. PHP also works with Microsoft Internet Information Services (IIS) and others.