First drive with PHP

Lets create a simple php script. Before we run this script make sure that you have wamp server running on your computer. If not then execute the wamp server.

In windows, go to start, type wamp and press enter.

Also make a folder named 'phpScripts' inside 'www' folder present within the 'wamp' directory. Here we are going to save our php scripts.

Now open your editor(notepad) and write the code as shown below:

<?php
	echo phpinfo();
?>

Save this program with a name first.php inside the phpScripts folder. You can use any name of your own, just make sure that you end it with .php extension. Also, here echo is used to print the output.

After saving it, open your browser and type url as 'localhost'.

Under the heading 'Your Projects' you can see your folder 'phpScripts'. Click on that. You will be able to see your file that you have just created named first.php.

Now click on the file. You will see the output.

phpinfo() function

Here, we are using a simple pre-defined php function 'phpinfo()' that returns a lot of information including php version.

phpinfo() is generally used for checking the configuration settings on a given server. It can be used to get the php environment, extensions used, server environment etc. It can also be used for debugging purpose.

Don't get daunted by this function. You will soon get used to it. Just follow this guide and you will know the basics of PHP. In the next article lets talk more about PHP.

<< Introduction to PHP PHP Tags >>