PHP If ElsePHP if-else statement is used to test condition. There are various ways to use if statement in PHP. PHP If StatementPHP if statement allows conditional execution of code. It is executed if the condition is true. If the statement is used to executes the block of code that exists inside the if statement only if the specified condition is true. SyntaxExample <?php Output: 12 is less than 100
PHP If-else StatementPHP if-else statement is executed whether the condition is true or false. If-else statement is slightly different from the if statement. It executes one block of code if the specified condition is true and another block of code if the condition is false. Syntax if(condition){ Flowchart <?php Output: 12 is even number
PHP If-else-if StatementThe PHP if-else-if is a special statement used to combine multiple if?.else statements. So, we can check multiple conditions using this statement. Syntax if (condition1){ Flowchart Example <?php Output: B Grade
PHP nested if StatementThe nested if statement contains the if block inside another if block. The inner if statement executes only when the specified condition in outer if the statement is true. Syntax if (condition) { Flowchart Example
Output: Eligible to give vote PHP Switch Example <?php Output: 34 is smaller than 56 and 45 |
0 Comments: