Dreevoo.com | Online Learning and Knowledge Sharing
 
Home | Programs | Programming languages | PHP & MySQL | Start learning PHP - part 1
Guest
Click to view your profile
Topics
Programs
Languages
Recipes
Home
Shortcuts
 
 

Start learning PHP - part 1

In our first lesson we will learn some very basic steps in PHP which will be enough for you to start writing your very own PHP programs.

 
  Author: podtalje | Version: php.net | 5th February 2013 |  
 
 
1.
 

PHP is a server scripting language, and is a powerful tool for making dynamic and interactive Web pages.

If you need help setting up a PHP environment on your computer, please click here.

Files which contain PHP code should end with an .php extension.
Example:  index.php

PHP code should always be between the following marks:
<?php

?>


If you want to write a comment in PHP, the line should start with //

As an alternative, everything between /* and */ is also considered as comment.

 
 
2.
 

If we open our page in web browser, we will get the following result.

The reason for this is that by default we will only see HTML code.

PHP code is processed by server in since our code only contains one comment, we don't see any output.

 
 
3.
 

To print something on the page, we need to use echo command.

Example:
echo "Hello World!";

 
 
4.
 

If we now open the page in the browser, we will be able to see the output Hello World!.

 
 
5.
 

Of course in PHP you can also do many other things and one of the most common is to use arithmetic functions.

You can use addition, subtraction, multiplication and division.

A simple example of this is:
echo 5+5;

 
 
6.
 

In PHP you will also need to deal with variables.

Variables can store different values and you can also use variables in different arithmetic functions.

Example:
$valueA=5;
$valueB=10;

$valueC = $valueA * $valueB;

echo "Value of valueC is: $valueC";

 
 
7.
 

If you look at the output on the web page you will see the end result 50.

These were the basics steps that should help you start playing around with PHP.

Try a few variations of the examples shown in these lesson. In case of any problems or question just post on forum and you will soon get an answer.

Click here for the next PHP tutorial.

 
 
 
   
  Please login to post a comment
  Click to open user profile  
Billbong, 5th Feb 2013, 5:10 AM
That's fantastic! Can't wait for the next ones, thank you!
 
   
 
 
online learning made for people
Dreevoo.com | CONTRIBUTE | FORUM | INFO