·  If condition:

<?php

$score=100;

if($score=100){

echo"you are lucky!";

}

?>

·  If else :

<?php

$score=10;

if($score==100){

echo"you are lucky!";

}else{

echo"you are unlucky!";

}

?>

·  Ternary operator:

<?php

$w=123;

$msg=$w>100?"large":"small";

echo $msg;

?>

·  If-elseif-else:

<?php

$color="red";;

if($color=="blue"){

echo"your colour is blue";

}elseif($color=="pink"){

echo"your colour is pink";

}elseif($color=="yellow"){

echo"your colour is yellow";

}else{

echo"your colour is red";

}

?>

·  Single /double quotation:

<?php

$a="m";

//double quotation ""

echo "$a\n"."print the value of variable";

//single quote ''

echo'$a\n';

?>

·  Strops /var_dump function:

<?php

$a="hello";

echo var_dump(strpos($a,"ll"));

?>

·  Maximum number:

<?php

$num=array(10,20,30,40,50,100,90);

$max=$num[0];

$count=0;

$cmax=0;

foreach($num as $v){

if($max<$v){

$max=$v;

$cmax=$count;

}

echo "value",$v,"<br>";

$count+=1;

}

echo"the maximum number=$max ";

?>

·  Minimum number:

<?php

$num=array(10,20,30,40,50,100,90);

$min=$num[0];

$count=0;

$cmin=0;

foreach($num as $v){

if($min>$v){

$min=$v;

$cmn=$count;

}

echo "value",$v,"<br>";

$count+=1;

}

echo"the minimum number=$min ";

?>

·  Prime Number:

<?php

$number = 2 ;

while ($number < 100 )

{

$div_count=0;

for ( $i=1;$i<=$number;$i++)

{

if (($number%$i)==0)

{

$div_count++;

}

}

if ($div_count<3)

{

echo $number." , ";

}

$number=$number+1;

}

?>

·  Even Number:

<?php

for($i=1; $i<=100;$i++){

if(($i%2)==0){

echo $i."<br>";

}

}

?>

·  Odd Number:

<?php

for($i=1; $i<=100;$i++){

if(($i%2)){echo $i."<br>";}

}

?>

·  Average Number:

<?php

$num=array(1,2,3,5,10);

$sum=0;

for($i=0; $i<5;$i++){

$sum=$sum+$num[$i];

$aver=$sum/5;

}echo $aver;

?>

·  Loops Program:

<?php

//for loop

echo"program of loops";

echo "<br>";

echo "for loop result:";

echo "<br>";

for($x=1;$x<=10;$x++)

{

echo $x,"<br>";

}

echo "<br>";

echo "do-while loop result:";

echo "<br>";

$y=10;

do{

echo $y,"<br>";

$y--;

}while($y>=1);

echo "<br>";

echo "while loop result:";

echo "<br>";

$z=10;

while($z>=5){

echo $z,"<br>";

$z--;

}

?>

·  Switch Program:

<?php

$favcolor = "red";

switch ($favcolor) {

case "red":

echo "Your favorite color is red!";

break;

case "blue":

echo "Your favorite color is blue!";

break;

case "green":

echo "Your favorite color is green!";

break;

default:

echo "Your favorite color is neither red, blue, nor green!";

}

?>