Hi.. welcome again in my page in “have-fun-and-enjoy.blogspot.com”.
And knowledge of PHP was enter to IF and ELSE in PHP. Do you understand by my
previous tutorial ? I hope you understanding with my tutorial.
Likely other programming language PHP
too having statement “IF AND ELSE”. Define from IF and Else is statement was
present by PHP for choice wheter program can next or must stop. If program is
true then program next and if statement is false the program must choice other
statement.
Condition in PHP :
- IF
- IF ELSE
- IF, ELSE IF, ELSE
Ok direct to example…
IF AND ELSE
We want making program if value more
then equal to 60 then pass and if value less than 60 then fail.
You can copy this coding…
Example 1:
<?php
$a = 70;
if ($a >= 60)
{
echo "Your Value is : ", $a,
" and you PASS";
}
else
{
echo "Your Value is : ", $a,
" and you FAIL";
}
?>
And result is :
Your Value is : 70 and you
PASS
Look on “$a = 70” if you
change be “$a = 40”
And result is :
Your Value is : 40 and you
FAIL
IF, ELSE IF, ELSE
I want making program. You
can copy and paste in your notepad
Example 2 :
<?php
$a = 80;
if ($a >= 85)
{
echo "your getting A";
}
else if ($a >= 75)
{
echo "your getting B";
}
else if ($a >= 60)
{
echo "your getting C";
else if ($a >= 45)
{
echo "your getting D";
}
else
{
echo "your getting E";
}
?>
And result is :
your getting A
if in “$a =40”
and result is :
your getting E
If you any questions please
leave the comment..
Ok just it…
Thanks for you
Don’t forget come back
See you later
No comments:
Post a Comment