PHP (PHP: Hypertext Preprocessor) is an
open-source, programming language. PHP as most of us will be using
it runs as a web sever application. It takes the output of the
written code, the script, and processes it to produce a complete
page that can be displayed in a browser. PHP also allows dynamic web
pages to be created from functions or data that is stored in a
database.
In the 12 short years since the initial creation, PHP has
transformed the web hosting industry. The 4.x version which is
currently widely installed was released in May 2000. PHP 5 was
released in July 2004. PHP has delivered what the SSI functions
teased us with.
The basic PHP instructions are fairly easy to learn. PHP only
processes the portion of a page that is enclosed within the PHP tags
<?php ?>.
Here is a very short PHP script. The
portion that I have highlighted in red is what will be displayed on
the screen. If you run this script, it will simply print Hello,
Word! to the screen. Try it.
<?php
echo 'Hello, World!';
?>
This script will print Hello. It really is a
nice day. Goodbye! to the screen. Notice that in this example
that the PHP tags are opened and closed twice and there is just
plain text in the middle. Try it.
<?php
echo 'Hello';
?>
It really is a nice day.
<?php
echo 'Goodbye!';
?>
PHP treats anything not inside the <? ?> tags as standard
html. Because it is so easy to intermix PHP code and standard html
many beginners do it this way. In these examples there really is no
harm in doing it that way. In long and complex scripts it is best to
completely separate the code from the html by using templates or
"text only pages" and using the include function of PHP.
Using PHP this page could have been
created from 4 different sources. The header, menu, main and footer
could all be different pages and could be included here to form one
page.
If you have a large site with many
pages it is much easier to update one header, menu or footer and
have the changes appear across the entire site.
There are many great sites where you can learn PHP; so we won't do a
poor job of duplicating their efforts here.
|