Tuesday, November 24, 2009

How to start PHP Programming. Write your First Program in PHP

Here I will show how to start php programming. Lot of my friends like php, but there is a starting trouble. This will help you to write your first php program.

You need to install LAMP (Linux Apache, Mysql, PHP )Server.
Click Here How to install LAMP Sever in Ubuntu Linux

Now you can check your Apache webserver

Open a browser (firefox) and type http:// 127.0.0.1 in address bar

It Shows " It Works "

Now you can test your PHP

See your server root is pointed to the folder /var/www by default. So you have to save your programs in /var/www. But There is a problem, you can't write in to the folder /var/www as ordinary user, it needs root privilege . (I am using gksu for solving this proble, it will ask for your sudo password)

open a terminal type the following

$cd /var/www

$ gksu gedit helloworld.php

write the program
<?php
echo "hello world";
?>
now save and quit

open browser (firefox)

type the following in the address bar
http://127.0.0.1/helloworld.php

Now You will get the result in the browser

" hello world"

Now your First PHP program is Working

write valuable comments for helping php beginners

3 comments:

disaster said...

simple but useful

musta34 said...

write more tutorials in php and mysql

Unknown said...

Really useful
thanks allot...