Translate

Monday, May 5, 2014

8.Control Structure (Select)

Select structure

if Statement

Syntax:
if(condition) statement;
if(condition)  
{
   statements;  

}
if(condition):    
   statements;  
endif;
example
<?php
  $bool= true;
  if ($bool) echo "True Condition";
?>

if...else Statement

Syntax:
if(condition) statement;
else statement;
if(condition)
{
  statements;
}
else
{
  Statements;
}
if(condition):
  statements;
else:
  statements;
endif;
example
<?php
  $bool= true;
  if ($bool) echo "True Condition";
  else echo "False Condition";
?>

if...elseif....else Statement

Syntax:
if(condition) statement;
elseif(condition) statement;
else statement; // Optional

Ternary

Syntax:
condition? true condition : false condition;

0 comments:

Post a Comment