How PHP Works?

PHP is an embedded scripting language when used in Web pages. This means that PHP code is embedded in HTML code. You use HTML tags to enclose the PHP language that you embed in your HTML file the same way that you would use other HTML tags. You create and edit Web pages containing PHP the same way that you create and edit regular HTML pages. The PHP software works in conjunction with the Web server. The Web server is the software that delivers Web pages to the world. When you type a URL into your Web browser, youe sending a message to the Web server at that URL, asking it to send you an HTML file. The Web server responds by sending the requested file. Your browser reads the HTML file and displays the Webpage. You also request the Web server to send you a file when you click a link in a Web page. In addition, the Web server processes a file when you click a Web page button that submits a form.

When PHP is installed, the W Web server is configured to expect certain file extensions to contain PHP language statements. Often the extension is .php or .phtml, but any extension can be used. When the Web server gets a request for a file with the designated extension, it sends the HTML statements as-is, but PHP statements are processed by the PHP software before they are sent to the requester. When PHP language statements are processed, only the output is sent by the Web server to the Web browser. The PHP language statements are not included in the output sent to the browser, so the PHP code is secure and transparent to the user. For instance, in this simple PHP statement:

<?php echo “<p>Hello World”; ?>

is the closing tag. echo is a PHP instruction that tells PHP to output the upcoming text. The PHP software processes the PHP statement and outputs this:

<p>Hello World

which is a regular HTML statement. This HTML statement is delivered to the user browser. The browser interprets the statement as HTML code and displays a Web page with one paragraph Hello World. The PHP statement is not delivered to the browser, so the user never sees any PHP statements.

PHP and the Web server must work closely together. PHP is not integrated with all Web servers, but it does work with many of the most popular Web servers. PHP is developed as a project of the Apache Software Foundation par consequently, it works best with Apache. PHP also works with Microsoft IIS/

PWS, iPlanet (formerly Netscape Enterprise Server), and others. Although PHP works with several Web servers, it works best with Apache. If you can select or influence the selection of the Web server used in your organization, select Apache. By itself, Apache is a good choice. It is free, opensource, stable, and popular. It currently powers over 60 percent of all Websites, according to the Web server survey at It runs on Windows, Linux, Mac OS, and most flavors of Unix.