Learn PHP the Easy Way

ad space

If you're a bit new to Web development, you would probably be a bit overwhelmed with the vast variety of indecipherable acronyms that have confounded you at one point or another.

However, you should know that if the domain that you want to enter is the Web development domain, there is only one acronym that you need to familiarize yourself with-that is "PHP".

The acronym PHP is a recursive initialism that means "Hypertext Preprocessor." You should know that PHP is the only open-source server-side scripting language. It is a computer language that is quite fun and easy to learn.

Statistics show that more than 16,000,000 Web sites use PHP as their native server side scripting language. It is also the type of computer language that is the most popular across various Apache modules.

One of the things that you need understand about PHP is that unlike CGI scripts which require you to write code to output HTML, PHP allows you to embed PHP code in regular HTML pages and then execute the embedded PHP code whenever the page is requested.

An example of how HTML and PHP can be combined is through the following code:


Agent:So who do you think you are, anyhow?


// print output
echo 'Neo: I am Neo, but my people call me The One.';
?>

The above code essentially embeds a PHP script within the HTML code. You will learn that when you request for the page and you look at the HTML source, you won't find the PHP syntax within it because Apache intercepted your request and then gave it off to PHP.

What PHP did is that it parsed the script and executed the code in between the marks and replaced it with the output of the code run. The resulting output was then given back to the server and was passed on to the client. Since the output contained valid HTML in the web site's code, the browser was essentially able to display it.

If you dissect the script and look closely, you will discover the basic syntactical rules of PHP. The syntax that PHP has uses a semi-colon. This is quite similar to Perl and taking out the semi-colon is one of the most common mistakes newbie's make. With that being said, it is quite normal to terminate the last line of a PHP block without a semi-colon.

So there you have it, your introductory lesson in PHP!