Before you start writing your pages in PHP, you should know a few things about this great language.
PHP (officially, this acronym is a recursive acronym for “PHP: Hypertext Preprocessor”) is a general-purpose scripting language, open source, and specially designed for web application development. It can be easily integrated into your HTML pages.
The PHP code that you will insert in your WEB pages will be detected by a WEB server (if it is provided with the PHP extension) that will send it to PHP to interpret it (I speak well of interpretation and not of compilation).
For information you should know that PHP is supported by many WEB servers, including the famous Apache project.
Thanks to these portions of PHP code that you will insert in your WEB pages, PHP will allow you to quickly write WEB pages with dynamic contents.
Especially if it is coupled with a relational database server such as MySQL.
How it works
There is a difference with other CGI scripts written in other languages such as Perl or C: instead of writing a program with many command lines to generate an HTML page, with PHP, you write an HTML page with PHP code included inside to perform a specific action.
The PHP code is included between a start tag and an end tag that allow the web server to switch to “PHP mode”.
The knowledge of the HTML code is thus strongly advised, even essential to start its first pages in PHP (this because the PHP only generates HTML code; and that it is inconceivable to generate something that one does not control).
It is also important to know that when you insert the smallest piece of PHP code in an HTML page, you will have to change the extension of this file to .php (in plain English: if you have a page named index.htm and you insert PHP code in it, you will have to rename it to index.php).
As we have just seen, it is quite possible to mix, within the same WEB page, HTML instructions and PHP instructions.
Only, so that the server which hosts you can locate the portions of code in PHP, it is enough to indicate the beginning as well as the end of the PHP code. These marks that delimit the code portion are called :
we will use the tag <?php to mark the beginning of a portion of PHP code
the ?> tag is used to mark the end of a portion of PHP code
The instructions of the PHP code will naturally be placed between these two tags.