Introduction to PHP Learning Guide
From Wikiversity
PHP is a significant language, with millions of practical applications used for a variety of commercial and non-commercial purposes. It is installed on thousands of web servers worldwide, and web hosts consider using PHP on their servers for other applications e.g. hosting control panels. Due to the greatly increased availability over other web languages (Perl for instance), PHP has grown rapidly and knowledge of it can even lead to a high paying job. However, today we're going to start out small and teach you the basics, step by step, of the Wikiversity Introduction to PHP.
<html> <head> <title>hi</title> </head> <body> 123456 </body> </html>
[edit] Prerequisites
Just to clarify, some of the prerequisites listed at Introduction to PHP don't even exist yet (as of 6/10/06), so in lieu of them we suggest you run through the basics of w3schools.com's HTML tutorial and the first few lessons of its Javascript tutorial.
[edit] Basic syntax
As this is your first PHP lesson, we'll cover this section in detail. How web servers handle programming languages is quite simple - they look for certain file extensions (the .whatever in the file name) and run specific commands depending on the file type. In this instance, web servers look for .php in the file name, and instead of simply sending the file across, they call a program called php.exe and pass the file to it. php.exe then parses (interprets) it before sending the output back to the web server.
However, there is a very useful feature of PHP that requires some further insight here. This feature is PHP's ability to effectively jump in and out of 'PHP mode', so that, at times, normal HTML can be used in scripts. This is a basic example:
<html> <body> <?php ?> </body> </html>
Notice that normal html tags are wrapped around the php. If this were a .html file, what would be sent to your web browser is exactly the above.