What is PHP?
PHP is a server-side scripting language (versus a client-side scripting language like Javascript, which does all of its work on an end-user browser). PHP is open and free to use, and typically runs as a module under the Apache web server.
Dynamic vs. Static Pages
PHP works to help you create dynamic pages. Whereas plain .htm or .html files are stored in their complete form on a server somewhere, .php (the commonly-used file extension for files that include PHP code) files exist in a partially-completed form; when a user requests a .php file, the server must parse (basically, interpret) the code and take any actions the PHP code demands, before sending it to the user.
Think of it like this: when a user requests static XHTML or HTML pages, the server storing them acts like a vending machine that sells candy bars. The user's computer says, "Give me a candy bar" and the server offers the candy bar. However, when a user requests a PHP page, it's like going to a restaurant and saying, "Give me a cheeseburger, but hold the mayo, and add lettuce, tomato, pickles, and onions." The server has all of the ingredients for the page, but must assemble them before sending the completed page to the user—just like a restaurant has all of the ingredients for your burger, but must prepare them before bringing the completed work to your table.
How Do I Know if my Server Handles PHP?
Most Web hosting services have a list of languages and other goodies available for their users' accounts. However, you can test for PHP by copying and pasting this small chunk of code into a blank text file and uploading it to your server. Make sure you name the file test.php or something with the .php extension!
<?php
$testvariable = "Hello!";
print $testvariable;
?>
If PHP is enabled on the Web server you use, when you request this file through your Web browser, you should have a document that just says Hello!. If you see the exact code you've written, something's not right and you'll need to contact your IT staff or Web hosting service provider to find out if you can run PHP on your site.
Updated on Mon. Apr. 3 2006 at 11:43AM