PHP conditional statement

PHP conditional statement

PHP – if: If the expression is evaluated to true, the condition.
if ($x > $y)
     echo "x is bigger than y";

PHP – if else: The PHP’s if else statements are used to perform different actions based on conditions.
Below a variable number is assigned a value 1. ‘if statement’ checks for the value. Since it is evaluated to “1”, it displays the message.
$number = 1;

If ($number ==1)

     Echo “The number 1”;

} else

     Echo “not number 1”;



The number 1
PHP case switching
PHP – Switch case: Switch case can be considered to be like multiple if else statements.
PHP loop
PHP – While loop: while loops check for the expression. If it is evaluated to true, the subsequent statement is executed.
PHP function
PHP has around hundreds of inbuilt for functions which makes it a very powerful language.
Post your comment