if Statement in PHP
Notes:
PHP Conditional Statements:
Conditional / selection statements:
- help us to execute set of statements based on the result of a given conditional expression
if,
if else,
else if ladder,
switch case
if statement:
- executes true part; if the conditional expression inside the parenthesis evaluates to true.
syntax:
if(conditional expression)
{
statements; // true part
}
OR
if (conditional expression):
statements // true part
endif;
Example Code:
$a=10;
if($a==10)
{
echo "a is equal to 10";
}
OR
$a=10;
if($a==10):
echo "a is equal to 10";
endif;
Interview Questions:
1. PHP stands for ______________
a. Hypertext Preprocessor
b. Preprocessor Hypertext
c. Personal Home Processor
d. Personal Hypertext processor
Ans: a