Program 1:
<html>
<head<title> Firest PHP Code</title</head>
<body>
<h1>Hello This is HTML</h1>
<?php
echo "This is PHP";
?>
</bodt>
</html>
Program 2:
<html>
<head<title</title</head>
<body>
<h1>Hello This is HTML</h1>
<pre>
<?php
$f1=10;
$_A1=20;
$sum=$f1+$_A1+"10"+"20";
echo "This is PHP\n";
echo ("The value =$f1 and the second value=$_A1\n");
echo "\n sum=$sum\n"
?>
</pre>
</body>
</html>
Program 3:
<html>
<head<title</title</head>
<body>
<h1>Hello This is HTML</h1>
<pre>
<?php
$f1=10;
$_A1=20;
$sum=$f1+$_A1+"10"+"20";
echo "This is PHP\n";
echo ("The value =$f1 and the second value=$_A1\n");
echo "\n sum=$sum\n","Hii";
print "\n sum=$sum\n";
?>
</pre>
</body</html>
Program 4:
<html>
<head<title</title</head>
<body>
<h1>Hello This is HTML</h1>
<pre>
<?php
$grade=10;
if($grade>=60)
echo "Passed\n";
else
echo "Failed\n";
?>
</pre>
</body>
</html>
Program 5:
<html>
<head<title</title</head>
<body>
<h1>Hello This is HTML</h1>
<pre>
<?php
$grade=101;
if($grade>100 || $grade<0)
echo"Erroe";
else
if($grade<=60)
echo "Passed\n";
else
echo "Failed\n";
?>
</pre</body</html>
Program 6 (Grads):
<html>
<head<title</title</head>
<body>
<pre>
<?php
echo"<h1>This is PHP</h1>";
$mark=70;
if($mark>100 || $mark<0)
echo "Error";
else if($mark>=90)
echo "A";
else if($mark>=80)
echo "B";
else if($mark>75)
echo "C+";
else if($mark>70)
echo "C";
else if($mark>65)
echo "D+";
else if($mark=60)
echo"D";
else echo"F";
?>
</pre</body</html>
Program 7 (Array and defined maximum and index):
<html>
<head<title</title</head>
<body>
<pre>
<?php
$stuff=array(100,50,60,70,90);
$max=$stuff[0];
$count=0;
$cmax=0;
foreach($stuff as $v)
{
if($max<$v)
{
$max=$v;
$cmax=$count;
}
echo "Val=", $v, "\n";
$count+=1;
}
echo"The maximum= $max and index=$cmax";
?>
</pre>
</body>
</html>
Program 8(Douable Quote)
<html>
<head<title> Firest PHP Code</title</head>
<body>
<h1>Douable Quote</h1>
<pre>
<?php
echo "This is a simple string\n";
echo "you can also have embedded newlines in
string this way as it is
okey to do";
echo "This will expand: \n a newline";
$expand = 12;
echo " variables do $expand\n ";
?>
</pre>
</bodt>
</html>
Program 9(Increment & Decrement)
<html>
<head<title> Firest PHP Code</title</head>
<body>
<h1>Increment & Decrement</h1>
<pre>
<?php
//post
$x=12;
$y=15 + $x++;
echo "x is $x and y is $y\n";
//pre
$x=12;
$y=15 + ++$x;
echo "x is $x and y is $y\n";
?>
</pre>
</bodt>
</html>
Program 10 (Strpos)
<html>
<head<title> Firest PHP Code</title</head>
<body>
<h1>Strpos</h1>
<pre>
<?php
$a ="Hello";
echo var_dump(strpos($a,"wo"));
$a=$a."world";
echo strpos($a,"wo");
?>
</pre>
</bodt>
</html>
Program 11
<html>
<head<title> Firest PHP Code</title</head>
<body>
<h1>Hello</h1>
<pre>
<?php
$number=100;
$msg=$number>100 ?"large":"small";
echo"$msg";
?>
</pre>
</bodt>
</html>
Program 12
<html>
<head<title</title</head>
<body>
<pre>
<?php
echo"<h1>if...elseif</h1>";
$mark=80;
if($mark>100 || $mark<0)
echo "Error";
elseif($mark>=90)
echo "A";
elseif($mark>=80)
echo "B";
elseif($mark>75)
echo "C+";
elseif($mark>70)
echo "C";
elseif($mark>65)
echo "D+";
elseif($mark=60)
echo"D";
else echo"F";
?>
</pre</body</html>
Program 14
<html>
<head<title> Firest PHP Code</title</head>
<body>
<h1>Hello This is HTML</h1>
<pre>
<?php
$fuel=10;
while($fuel>1)
{
print"Hello World\n";
$fuel =$fuel -1;
}
?>
</pre>
</bodt>
</html>
Program 15
<html>
<head<title> Firest PHP Code</title</head>
<body>
<h1>Hello This is HTML</h1>
<pre>
<?php
$count=1;
do{
echo "$count times 5 is". $count*5;
echo"\n";
}while(++$count<=5);
?>
</pre>
</bodt>
</html>
Program 16
<html>
<head<title> Firest PHP Code</title</head>
<body>
<h1>Hello This is HTML</h1>
<pre>
<?php
for($count=1; $count<=6; $count++)
{
echo "$count times 6 is". $count*6;
echo"\n";
}
?>
</pre>
</bodt>
</html>
Program 17
<html>
<head<title> Firest PHP Code</title</head>
<body>
<h1>Hello This is HTML</h1>
<?php
$s ="Hi xe, My name is xe, I am working with Prof.xe in xe";
$temp = $s;
$found=true;
$counter=0;
while($found!== False)
{
$found=strpos($temp,"xe");
if($found !==false)
{
echo "xe : $found\n";
$temp[$found]="F";
$counter++;
}
}
echo "The number of xe in the statement is =$counter\n";
?>
</bodt>
</html>
Program 18
<html>
<head<title> Firest PHP Code</title</head>
<body>
<h1>Hello This is PHP</h1>
<pre>
<?php
for($count=1; $count<=600; $count++)
{
if($count==5)break;
echo "Count: $count\n";
}
echo "Done\n";
?>
</pre>
</bodt>
</html>
Program 19 (Even number)
<html>
<head<title> Firest PHP Code</title</head>
<body>
<h1>Hello This is PHP</h1>
<?php
for($c=1; $c<=100; $c++)
if(($c%2)==0){
echo $c.", ";
}
?>
</bodt>
</html>
Program 19 (Print the word from last character to first)
<html>
<head<title> Firest PHP Code</title</head>
<body>
<h1>Hello This is PHP</h1>
<?php
$stat="Hello";
for($c=4; $c>=0; $c--)
echo "$stat[$c]";
?>
</bodt>
</html>
Program 20
<html>
<head<title> Firest PHP Code</title</head>
<body>
<h1>Hello This is PHP</h1>
<pre>
<?php
$stat="Hello world Hello Hello Loo ";
$temp="";
$tem=array();
$s=0;
for($count=0; $count<strlen($stat); $count++)
{
if( " "!==$stat[$count])
$temp.=$stat[$count];
else{
$tem[]=$temp;
$temp="";
echo $tem[$s], "\n";
$s++;
}}
?>
</pre>
</bodt>
</html>
Program 21
<html>
<head<title> Lab Quiz</title</head>
<body>
<pre>
<?php
$s ="Hel My name is el. I am working in el street in USA. Can you give me your el address.";
$temp = $s;
$found=true;
$counter=0;
$start=0;
$out="";
while($found!== False)
{
$found=strpos($temp,"el");
if($found !==false)
{
$temp[$found]=" ";
for($i=$start; $i<=$found+1; $i++)
$out.= $s[$i];
$out.= "lo";
$start=$found+2;
$counter++;
}
}
echo "Number of el is =$counter\n";
echo "$out";
?>
</pre>
</body>
</html>