In this php tutorial i will discuss about use of if else condition in php. The syntax of if else condition in php is almost same with c language. We use if else statement when there is some sort of condition involve in php program. Code block is executed if condition is true and another code code block is executed for alternate situation.
if else condition in php
<?php $name="Muhammad Ali"; if($name=="Muhammad Ali") { echo "Welcome Muhammad Ali"; } else{ echo "Welcome User"; } ?>
Note:- == is called equal to operator that lies under logical operators category.
else if condition in php
Let's have a look over else if condition in php
<?php $name="Muhammad Ali"; if($name=="Muhammad Ali") { echo "Welcome Muhammad Ali"; } else if($name=="David") { echo "Welcome David"; } else{ echo "Welcome Guest"; } ?>
I hope you have learned a lot about if else condition in php.
0 comments:
Post a Comment