PHP Programs
PHP Programs
HTML
<html>
<head>
<body>
<font size="5">
</font>
</form>
</body>
</head>
</html>
armstrong.php
<html>
<head>
<body>
<font size="5">
<?php
$n=$_POST['num'];
function arm($n)
$d=0;
$sum=0;
$num=$n;
while($n>0)
$d=$n%10;
$sum=$sum+($d*$d*$d);
$n=$n/10;
if($sum==$num)
else
arm($n)
?>
</font>
</body>
</head>
</html>
2) Identifying Biggest and Smallest Number in an Array
HTML
<html>
<head>
<body>
<font size="5">
</font>
</form>
</body>
</head>
</html>
arrays.php
<html>
<head>
<body>
<font size=5>
0 <?php
$n=$_POST['num'];
$b=$_POST['b'];
$b=explode(",",$b);
$length=count($b);
$big=$b[0];
$small=$b[0];
$i=1;
if($length==$n)
for($i=0;$i<$n;$i++)
if($b[$i]>$big)
$big=$b[$i];
if($b[$i]<$small)
$small=$b[$i];
for($i=0;$i<$n;$i++)
echo $b[$i]."<br>";
else
?>
</font>
</body>
</head>
</html>
3) Factorial
HTML
<html>
<head>
</head>
<body>
<center>
</center>
</form>
</font>
</body>
</html>
mystyle.css
body {
background-image: url("image.jpg");
background-color: #cccccc;
height: 500px;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
find.php
<html>
<body>
<font size=6>
<?php
$num=$_POST['num'];
$i=1;
$fact=1;
while($i<=$num)
$fact=$fact*$i;
$i++;
?>
</font>
</body>
</html>
4) Fibonacci Series
HTML
<html>
<body>
<font size=6>
</form>
</font>
</body>
</html>
print.php
<html>
<body>
<?php
$n=$_POST['num'];
$a=-1;
$b=1;
$i=1;
while($i<=$n)
$c=$a+$b;
$a=$b;
$b=$c;
$i++;
echo $c."<br>";
?>
</body>
</html>
<html>
<head>
<body>
<font size="5">
</font>
</form>
</body>
</head>
</html>
student.php
<html>
<head>
<body>
<font size=5>
<?php
$name=$_POST['na'];
$reno=$_POST['re'];
$m1=$_POST['m1'];
$m2=$_POST['m2'];
$m3=$_POST['m3'];
$total=$m1+$m2+$m3;
$ave=$total/3;
if($ave>=90)
else if($ave>=80)
else if($ave>=70)
echo "Grade : B+ <br>";
else if($ave>=60)
else if($ave>=50)
else if($ave>=40)
else
?>
</font>
</body>
</head>
</html>
6) Multiples of 7 and 8 using (include)
HTML
<html>
<head>
<body>
</form>
</font>
</body>
</head>
</html>
check.php
<html>
<head>
<body>
<?php
$arr=$_POST['a'];
$arr=explode(",",$arr);
$ch=$_POST['m'];
echo "Given Values<br>";
foreach($arr as $b)
echo $b."<br>";
if($ch==7)
include '7.php';
else if($ch==8)
include '8.php';
?>
</font>
</body>
</head>
</html>
7.php
<?php
for($i=0;$i<count($arr);$i++)
if($arr[$i]%7==0)
echo $arr[$i]."<br>";
}
8.php
<?php
for($i=0;$i<count($arr);$i++)
if($arr[$i]%8==0)
echo $arr[$i]."<br>";
7) Online Shopping
HTML
<html>
<body>
<style>
body{
background:linear-gradient(to left,skyblue,violet);
h1{
color:darkblue;
font-weigth:900;
font-size:45px;
font-style:italic;
}
table{
p{
font-weight:800;
font-size:20px;
text-align:center;
font-family:consolas;
color:darkblue;
#button{
background-color:skyblue;
padding:10px 20px;
border-radius:12px;
pointer:none;
#button:hover{
background-color:lightgreen;
pointer:none;
</style>
<font>
<center>
<table border=1><tr><td>
<p>
<br><br>Iphone 7
<br><br>Amount=Rs.7000<br>
</p>
<td>
<p>
<br><br>Black Berry
<br><br>Amount=Rs.5000<br>
</p>
<td>
<p>
<br><br>Any Cool
<br><br>Amount=Rs.10000<br>
</p>
<td>
<br><br>Iphone SE
<br><br>Amount=Rs.12000<br>
</p>
</center>
</form>
</body>
</html>
osc.php
<html>
<head>
<body>
<style>
body{
background:linear-gradient(to left,skyblue,violet);
h1{
color:darkblue;
font-weigth:900;
font-size:45px;
font-style:italic;
p{
font-weight:800;
font-size:20px;
text-align:center;
font-family:consolas;
color:darkblue;
</style>
<font>
<center>
<br>
<?php
$a=$_POST['b'];
$b=0;
$j=0;
echo "<p>";
for($i=0;$i<count($a);$i++)
$j=$j+1;
echo $j;
echo "Rs.".$a[$i]."<br>";
$b=$b+$a[$i];
echo "</p>";
?>
</body>
</html>
HTML
<html>
<head>
<body>
</form>
</font>
</body>
</head>
</html>
view.php
<html>
<head>
<body>
<?php
session_start();
if(isset($_SESSION['view']))
$_SESSION['view']=$_SESSION['view']+1;
else
$_SESSION['view']=1;
?>
</font>
</body>
</head>
</html>
HTML
<html>
<body bgcolor="pink">
<center>
</form>
</font>
</body>
</html>
check.php
<html>
<body>
<?php
$num=$_POST['num'];
if($num>0)
else if($num<0)
else
?>
</body>
</html>
HTML
<html>
<head>
<body>
<font size="5">
</font>
</form>
</body>
</head>
</html>
reverse.php
<html>
<head>
<body>
<font size="5">
<?php
$n=$_POST['num'];
function rever($n)
$d=0;
$ans=0;
while($n>1)
$d=$n%10;
$ans=($ans*10)+$d;
$n=$n/10;
return $ans;
}
?>
</font>
</body>
</head>
</html>
HTML
<html>
<body bgcolor="pink">
</form>
</body>
</html>
si.php
<html>
<body>
<h1>
<?php
$p=$_POST['p'];
$n=$_POST['n'];
$r=$_POST['r'];
$si=$p*$n*$r/100;
$amount=$p*pow((1+$r/100),$n);
$ci=$amount-$p;
?>
</h1>
</body>
</html>
HTML
<html>
<head>
<body>
<font size="5">
</font>
</form>
</body>
</head>
</html>
string.php
<html>
<head>
<body bgcolor="cyan">
<font size=5>
<?php
$ch=$_POST['ch'];
$s1=$_POST['s1'];
$s2=$_POST['s2'];
$s3=$_POST['s3'];
$s4=$_POST['s4'];
$s5=$_POST['s5'];
$s6=$_POST['s6'];
switch($ch)
case 1:
if(strcmp($s1,$s2)==0)
else
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
?>
</font>
</body>
</head> </html>
HTML
<html>
<head>
<body>
<font size="5">
</font>
</form>
</body>
</head>
</html>
sum.php
<html>
<head>
<body>
<font size="5">
<?php
$n=$_POST['num'];
$d=0;
function sum_of_digits($n)
$ans=0;
while($n>0)
$d=$n%10;
$ans=$ans+$d;
$n=$n/10;
return $ans;
?>
</font>
</body>
</head>
</html>
HTML
<html>
<body bgcolor="tomato">
<p>volume cylinder</p>
</form>
</body>
</html>
volume.php
<html>
<body>
<h1>
<?php
$r=$_POST['r'];
$h=$_POST['h'];
$cy=$r*$r*$h;
$r1=$_POST['r1'];
$sp=4/3*(3.14)*$r1*$r1*$r1;
?>
</h1>
</body>
</html>
15) Voter Eligiblity
HTML
<html>
<body bgcolor="tomato">
</form>
</body>
</html>
vote.php
<html>
<body>
<?php
$s=$_POST['age'];
if($s>=18)
else
?>
</body>
</html>