PHP BASIC CODING (cont…)
(cont….)
V. Operators in PHP
*Arithmetic Operators*
+ addition
- subtraction
* multiplication
/ division
% modulus (division remainder)
++ increment
– decrement
*Comparison Operators*
== equal to
!= not equal
> greater than
= greater than or equal
<= less than or equal
*Logical Operators*
&& and
|| or
! not
I know its self explanatory…
VI. IF….Else Statements
If (condition)
//*Things to be executed if the answer to the condition is true*//
else
//*Things to be executed if the answer to the condition is false*//
If…else statement is use if the user wants to execute a set of code when the condition is true and another if the condition is not true.
VII. Switch Statement
switch (expression)
{
case 1:
//*code to be executed*//
break;
case 2:
//*code to be executed*//
break;
default:
//*code to be executed*//
break;
}
Switch statement is use if you want to select one of many blocks of code to be executed. this statement is used to avoid long blocks of if…elseif..else.
VIII. Looping Statement
while(condition)
code to be executed;
While statement is used to execute a block of code if and as long as a condition is true
do
{
code to be executed;
}while (condition)
Do—while statement is used to execute a block of code at least once and it will repeat the loop as long as the condition is true.
for each (array as value)
{
code to be executed;
}
For each statement is used to loop through arrays.
I think this is already enough and it has added new knowledge to those who are new in PHP… good luck and happy coding…
![]()
image source: www.cass.rrhosting.com
