[PHP] Create a if else statement

A Place To Talk About HTML,SHTML,XHTML, HTM,XML,CSS, JS,PHP,,Etc
Post Reply
User avatar Romania
Dragosvr92
Administrator
Administrator
Posts: 1128
Joined: 11 Sep 2009, 06:04
Name: Dragoș-Valentin Rădulescu
Location: Romania
Age: 32
Contact:

[PHP] Create a if else statement

Post by Dragosvr92 »

A If Else Statement is telling you if a condition is true or false...
bellow are some examples :

Code: Select all

 if ($Condition) {
echo "Condition is True";  
}
else{ 
echo "Condition is False";
}
You may also use a short version of that with the fallowing script

Code: Select all


echo ($Condition)?"Condition is True" : "Condition is False";
The only difference between the two examples is that the second on is shorter and that it can be used in a string
for example :

Code: Select all


$string = ($Condition)?"Condition is True" : "Condition is False";
echo $string;
Formerly known as TheKiller
Post Reply