Variable in PHP

And real script or program involves some kind of working on a variable. Let us assume that you wish to calculate the area of a rectangle. You store the value of its length and breadth is two different variable. Then you can create third variable to hold the area of a rectagle. We can use assignment statement to find and print the area of the rectangel.

Formally, Variables in PHP are start with a dollar sign followed by the name of the variable. You typically name the variable such that it is similar to teh function it performs. Perhaps the best way to learn is by looking at the following code.
$length = 10;
$width = 5;
$area = $length * $width ;
echo $area;
This is a very simple program. The $lengtgh is a variable that is assigned value 10. The variable $width is assigned a value 5. Finally the valriable $area is assigned the value equal to the multiplication of the variables $length and $width. In the end we print the value of the $area variable.


It helps if your understanding, if you do some simple exercizes. Here are these

1. Write a php code that will has the value of the radius of the circle assigned initially to 10. Then print the area of the circle ( with value of pi = 3.14).

2. Write php code that will take length and width and will print the periphery of the rectangle ( using assignment statement).