Learn php variables

Now lets look at Comparison Operators, these statements will come in really handy when we start using if statements.

Comparison operators are used to compare values in order to make decisions. These operators are best used with if and while statements but are also great for testing conditions

examples:

$x = 3;
$y = 4;
== - means equals too
<= - means less than or equal too
>= - means greater than or equal too
< - means less than
> - means greater than
!= - mean not equal too.


Which of the following is true or false
$x == $y 	false (if $x was equal to 4 this statement would be true)
$x != $y 		true (3 is less than 4 - if $x was 4 it would be equal)
$x < $y  		true (3 is less that 4)
$x > $y  		false (false because 3 is not greater than 4)
$x <= $y  	true (again 3 is less than or equal to 4 - if $x was 4 this statement would be false)
$x >= $y  	false (false as 3 is less than or equal to 4, so the statement is false.


You will see better examples of this in the next section.

Finally in this lesson we will look at formatting text. We can combine both PHP and Html together in our output.
This allows us to create dynamic and interactive content.
Lets see an example:

<?php
	$mainbody="Hello World";
	echo "Hello World";
	echo "$maindbody";
?>



PHP is a server side language, the code is executed before the page is sent to the browser.
Thus you would only get to see Hello World. When executed your browser would display Hello World in the Title.

You can combine all html tags and php in this way.



php variables tutorials