Devdatta Kane : AJAX, PHP, Javascript

Saturday, June 24, 2006

Introduction to PHP

PHP is one of the most popular web scripting languages. PHP is known for its simplicity, elegance, flexibility yet it is powerful enough to handle upto enterprise requirements.
PHP stands for a recursive acronym PHP Hypertext Preprocessor. PHP is an open source project led by Rasmus Lerdorf and backed by the open source community. You can find out more about PHP at its official site - http://www.php.net
We will now begin with elementary building blocks of the PHP Language:

In order to run the examples in the tutorial you need to have a webserver such as Apache with PHP installed on it. You can obtain an all-in-one installer to install Apache and PHP named XAMPP at apachefriends.org.

Now we start with our favorite Hello World example:
<?
echo "Hello World!";
?>
Save the above code as hello.php in the webroot of your webserver. Then open your favorite browser and enter the address http://localhost/hello.php where localhost is the name of webserver.

In the above code fragment the tags <? .. ?> denote a php markup. These tags have special meaning. Whenever the web server is requested a file with the extension .php it passes on the file to the PHP Parser which scans the file for PHP markup tags which denote that the code has to be parsed and converted to HTML output.

In our example when server encounters with <? ?> it starts parsing the PHP code. In the example it executes the echo function generating text 'Hello World' which is then sent to the browser.

That's for today guys. We will go deeper into PHP with the upcoming article.

Comments are always welcome.

1 Comments:

Post a Comment

<< Home