What is PHP? written by Paul DuBois
PHP is a server-side embedded scripting language. To write a Web page using PHP, you embed PHP code within HTML. Here's a simple PHP-enabled Web page that displays the current date and time:
<html>
<p>
The current local time is
<?php echo date ("M d, Y h:m:s A") ?>.
</p>
</html>
When someone requests the page above, the code portion between the special markers is executed on the server host and replaced by its output, resulting in the final page that the Web server sends to the client's browser. There is no complicated setup; you include only the code you need to produce the output you want. This approach to Web scripting makes it easy to write dynamic pages that include content generated on the fly at the time a client requests the page. Combined with PHP's support for several database engines, it becomes very easy to query your database from within scripts and display up-to-the-minute content. If you track financial information, your Web pages can look up the current indicators from the database for display to your visitors. If you need to write interactive pages, PHP generates and processes forms. Visitors can fill in a form describing products they want to see; you can run the appropriate query to look up matching items from your database and produce a table that displays information about them. PHP can also be used to generate graphical or PDF output as well, and recent work is devoted toward giving PHP XML-processing capabilities. PHP is designed to operate in a Web server environment without being resource-intensive. This is especially true for PHP 4, which extends PHP 3's capabilities, but also executes scripts much more efficiently (sometimes an order of magnitude more quickly). This makes PHP well suited for use as a lightweight script-processing engine on high-performance Web sites. PHP hasn't been around as long as Perl, so it's not yet as widely used, and it doesn't yet enjoy the same breadth of external support that Perl does with CPAN. But PHP's popularity is growing rapidly. PHP has a shallow learning curve, so it's easy to get started and produce working Web scripts in a short time, particularly if you already know how to program in C. Availability of external support is increasing, too. PHP now has PEAR (PHP Extension and Add-on Repository), an archive serving much the same purpose as the Perl CPAN. Learn more! We suggest these sites:
For more hints and answers to frequently asked questions, visit our Tech Library. |