PHP IF and IF-Else


PHP IF and IF-Else
IF StatemenetIF is used to check whether a condition in if met, if yes, an operation performed, consider the example below:
<?
$ name = 'castle';
if ($ name == 'castle') {
       echo "My home is $name";
}
?>

IF .. ELSE Statement
Like the if statement, if.. else statement will check whether the conditions, if yes then the following operations if carried out, otherwise the operation is performed under else.

<?
$ conditions = 'hungry';
if ($ condition == 'hungry) {
       echo "I'll buy food";
} else {
       echo "I will not buy food";
}
?>

0 comments:

Post a Comment