All Loop Types in PHP

Loops are used to execute a block of codes until a certain condition is met. The main benefit of using a loop is to save the time and effort. This automates the repetitive tasks within a PHP program.There are four types of loops in PHP:- For Loop:- For loop execute a number of times until a specific counter is achieved.  While Loop:- while loop runs until a specific...

Decision Making With Switch Statement in PHP

If you want execute one block of code out of many, use switch statement. The switch statement is to avoid long block of if..elseif..else code. Below is switch statement syntax:- switch (expression) { case label1: code to be executed if expression = label1; break; case label2: code to be executed if expression = label2; break; default: code to be executed if...

ElseIf Statement in PHP - If More Than One Conditions is True

If there is a posibilities that several condition is true, then use elseif statement. Below is syntax for elseif statement in PHP:- if (condition) Code1 with posible true condition; elseif (condition) Code2 with posible true condition; else code with posible true condition; Example:- Below example will output “Have a nice weekend!” if the current day is Friday, and...

Know About The If...Else Statement in PHP

If one condition is true and another is false then if else statement is used. Below is syntax:- If (Condition)      Code with true condition; Else      Code with false condition; Example:- <html> <body>     <?php        $d=date("D");        if ($d=="Fri")      ...

All About Decision Making Statements in PHP

If, elseif and switch statement are used for making decision based on different situations.  Conditional statement can be used to make decisions. There are 3 decision making statements in PHP:- If…else statement:- If one condition is true and other is false then this statement is used. Elseif statement:- If there are more than one condition true this statement...

Recent Post

All Loop Types in PHP

Loops are used to execute a block of codes until a certain condition is met. The main benefit of using a loop is to save the time and effor...

Popular Posts