Вы находитесь на странице: 1из 4

STEP BY STEP TOWARDS UNDERSTANDING PHP LANGUAGE I have decided to publish his document so as to enable those who are

in need of understanding PHP as a powerful tool in designing dynamic websites. Unlike other programming languages such as cprogramming, vb, java ,C++ etc that requires special compilers PHP dont need that, the only things you must have includes: Server : such as WAMP serve/Apache must be installed in your computer Web browser: such as Mozilla Firefox, Google chrome, safari etc. Text editor: such as note pad, notepad++, powerpad,context etc Now after all the above components have been installed in your computer, the next step is to test if the server has been installed properly this is done by just opening up your browser , in the URL type localhost and if you are using any version of wamp server the following window will be automatically loaded as shown below

This shows that the WAMP server is installed correctly. If you want to run PHP first go to the local disc C then open up the folder named Wamp, after that inside the wamp folder go on and open up the folder named www this is known as the root folder and in this folder is where your project resides. So any PHP code to run on your browser you must saveit in this folder. Now let us start up this cool business Using the notepad++ or any text editor write the following codes <html> <head> <title>my first PHP program</title> </head> <body> <?php echo "Hello world!<br>"; echo "My name is Jacob Mwaipopo from Tanzania"; ?> </body> </html> After typing these few codes then go on and save this file as first.php I the www folder which is located in the wamp folder in C here the <br> tag is the html tag and is used to indicate the line break since html and php do work together

The php syntax is the same as in c-programming. Now lets take a look on variable in PHP, here the variables are simply defined by the dollar sign ($) followed by the name of that variable. Now lets run up the above program using the concept of variables in PHP <?php //declaring the variables $fname="Jacob"; $lname="mwaipopo"; $age="20"; //now printingout he results echo "my name is $fname $lname <br>"; echo "I am $age years old"; ?> The above concept of displaying the two variables in a single line will be well explained in the next tutorials. Now lets take a look o the if-else statement I PHP. Here the logic is that only the true statement will be executed otherwise it will not be executed, consider the following example below

<?php //lets take a look o he age concept by declaring the variable age $age="18"; if($age>18) { echo "you are old enough to drive in the high way"; echo "then drive safely"; } else { echo "you are not old enough to drive in the high way"; } ?> Here only the first statement will be executed since it complies with the condition that age is greater than 20.Remember to save this file by writing the file name then.php in the www folder.

Thanx for visiting www.pox10.blogspot.com keep on visiting this site and I the next session more other things will be offered in this php tutorial series.

For more information please contact: JACOB MWAIPOPO Phone: +255719053466 Email: jacobmwaipopo@gmail.com/mwaipopojc@yahoo.com

See you next time guys!!!!

Вам также может понравиться