Ex.
No : 1
ODD OR EVEN
Date :
/ / 2025
AIM :
To write a PHP program to check the given number is
Odd or Even.
PROGRAM :
<html>
<head>
<title>ODD OR EVEN</title>
</head>
<body bgcolor="orange"><pre>
<h2> ODD OR EVEN</h2>
<form name="fm"method="POST"action="<?php
$_PHP_SELF?>">
ENTER THE NUMBER : <input type="text"
name="num"><br><br>
<input type="submit" value="ACCEPT">
<input type="reset" value="CLEAR">
</form>
</body>
</html>
<?php
if(isset($_POST['num']))
$n=$_POST['num'];
if($n%2==0)
echo" The given number $n is even";
else
echo" The given number $n is odd";
?>
OUTPUT:
RESULT :
Thus the program was successfully completed.
Ex.No : 2
VOTING ELIGIBILITY
Date :
/ / 2025
AIM :
To write a PHP program for Voting Eligibility.
PROGRAM :
<html>
<head>
<title>ELIGIBLE FOR VOTE</title>
</head>
<body bgcolor="cyan">
<h2>ELIGIBLE FOR VOTE</h2>
<form name="fm" method="POST" action="<?php
$_PHP_SELF?>">
Enter your age:<input type="text" name="t1"><br><br>
<input type="submit" value="SUBMIT">
<input type="reset" value="CLEAR"><br>
</form>
</body>
</html>
<?php
if(isset($_POST['t1']))
{
$s=$_POST['t1'];
echo "<br>The age is:".$s;
if($s>=18)
echo "<br> you are eligible for vote";
else
echo "<br>you are not eligible for vote";
}
?>
OUTPUT:
RESULT :
Thus the program was successfully completed.
Ex.No : 3
SIMPLE INTEREST CALCULATION
Date :
/ / 2025
AIM :
To write a PHP program to check the simple interest.
PROGRAM :
<html>
<head>
<title>Simple Interest Calculation</title>
</head>
<body bgcolor="cyan">
<h2>SIMPLE INTEREST CALCULATION</h2>
<form name="fm" method="POST" action="<?php
$_PHP_SELF?>">
Enter Principal Amount:<input type="text"
name="prin"> <br><br>
Enter Number of Years:<input type="text"
name="year"> <br><br>
Enter Rate of Interest(%):<input type="text"
name="inte"> <br><br>
<input type="submit" value="Accept">
<input type="reset" value="Clear">
</form>
</body>
</html>
<?php
if(isset($_POST['prin']) && isset($_POST['year']) &&
isset($_POST['inte']))
{
$p=$_POST['prin'];
$n=$_POST['year'];
$r=$_POST['inte'];
$si=$p*$n*$r/100;
echo "<br>SIMPLE INTEREST IS : ".$si;
}
?>
OUTPUT:
RESULT :
Thus the program was successfully completed.
Ex.No : 4
BIGGEST NUMBER CHECKING
Date :
/ / 2025
AIM :
To write a PHP program for Biggest Number Checking.
PROGRAM :
<html>
<head><title>Biggest Among Three Numbers</title>
</head>
<body bgcolor="violet">
<h2>Biggest Among Three Numbers</h2> <pre>
<form name="fm" method="POST" action="<?php
$_PHP_SELF?>">
Enter First Number: <input type="text" name="num1">
<br><br>
Enter Second Number : <input type="text"
name="num2">
<br><br>
Enter Third Number : <input type="text"
name="num3">
<br><br>
<input type="submit" value="Accept">
<input type="reset" value="Clear">
</form>
</body>
</html>
<?php
if(isset($_POST['num1']) && isset($_POST['num2']) &&
isset($_POST['num3']))
{
$n1=$_POST['num1'];
$n2=$_POST['num2'];
$n3=$_POST['num3']; if($n1>$n2 && $n1>$n3)
echo "<br>First Number is BIGGEST:".$n1; else
if($n2>$n3)
echo "<br>Second Number is BIGGEST:".$n2; else
echo "<br>Third Number is BIGGEST:".$n3;
}
?>
OUTPUT :
RESULT :
Thus the program was successfully completed.
Ex.No : 5
ARITHMETIC OPERATIONS
Date :
/ / 2025
AIM :
To write a PHP program to perform the Arithmetic
Operations.
PROGRAM :
<html>
<head>
<title>ARITHMETIC OPERATION</title>
</head>
<body BGCOLOR="CYAN">
<h2>ARITHMETIC OPERATION</h2><pre>
<form name="fm" method="POST" action="<?php
$_PHP_SELF?>">
ENTER THE FIRST NUMBER :
<input type="text" name="num1"><br>
ENTER THE SECOND NUMBER :
<input type="text" name="num2"><br><br>
ENTER YOUR CHOICE : <select name="choice">
<option value="0">select</option>
<option value="1">ADDITION</option>
<option value="2">SUBTRACTION</option>
<option value="3">MULTIPLICATION</option>
<option value="4">DIVISION</option>
<option value="5">MODULUS</option>
</select><BR> <BR>
<input type="submit" value="RESULT">
<input type="reset" value="CLEAR">
</form>
</body>
</html>
<?php
if(isset($_POST['num1']) && isset($_POST['num2']))
{
$n1=$_POST['num1']; $n2=$_POST['num2'];
$ch=$_POST['choice'];
switch($ch)
{
case 1:
$a=$n1+$n2;
echo"Addition is:".$a;
break;
case 2:
$a=$n1-$n2;
echo"Subtraction is:".$a;
break;
case 3:
$a=$n1*$n2;
echo"Multiplication is:".$a;
break;
case 4:
$a=$n1/$n2;
echo"Division is:".$a;
break;
case 5:
$a=$n1%$n2;
echo"Modulus is:".$a;
break;
default:
echo"invalid choice";
}
}
?>
OUTPUT:
RESULT :
Thus the program was successfully completed.
Ex.No : 6
STRING OPEATIONS
Date :
/ / 2025
AIM :
To write a PHP program to perform string operations.
PROGRAM :
<html> <body bgcolor="pink">
<h2> STRING OPERATIONS </h2>
<form method="POST"> <h4>
Enter the String :
<input type="text" name="s"/><br><br>
<input type="submit" name="s1" value=" Length">
<input type="submit" name="s2" value=" Reverse">
<input type="submit" name="s3" value=" Palindrome">
<input type="submit" name="s4" value=" Uppercase ">
<input type="submit" name="s5" value=" Lowercase">
</form>
<?php
if(isset($_POST['s1']))
{
$n=$_POST['s'];
$l=strlen($n);
echo "<br><br> Length=$l";
}
if(isset($_POST['s2']))
{
$n=$_POST['s'];
$r=strrev($n);
echo "<br><br>Reverse=$r";
}
if(isset($_POST['s3']))
{
$n=$_POST['s'];
if(strcmp(($n),strrev($n))==0)
{
echo "<br><br>Palindrome";
}
else
echo "<br><br>Not a Palindrome";
}
if(isset($_POST['s4']))
{
$n=$_POST['s'];
$up=strtoupper($n);
echo "<br><br>Uppercase=$up";
}
if(isset($_POST['s5']))
{
$n=$_POST['s'];
$lr=strtolower($n);
echo "<br><br> Lowercase=$lr";
}
?>
</body>
</htm>
OUTPUT:
RESULT :
Thus the program was successfully completed
Ex.No : 7
SUM OF DIGITS
Date :
/ / 2025
AIM :
To write a PHP program for Sum of Digits.
PROGRAM :
<html>
<head>
<title>SUM OF DIGIT</title>
</head>
<body bgcolor="violet">
<h2>SUM OF DIGIT</h2>
<form name="fm" method="POST" action="<?php
$_PHP_SELF?>">
Enter the Number:<input type="text"
name="n1"><br><br>
<input type="submit" value="SUBMIT">
<input type="reset" value="CLEAR"><br>
</form>
</body>
</html>
<?php
if(isset($_POST['n1']))
{
$a=$_POST['n1'];
$s=0;
echo "The value is:".$a;
echo "<br>";
while($a>0)
{
$r=$a%10;
$s=$s+$r;
$a=$a/10;
}
echo "The result is:".$s;
}
?>
OUTPUT :
RESULT :
Thus the program was successfully completed.
Ex.No : 8
FACTORIAL CALCULATION
Date :
/ / 2025
AIM :
To write a PHP program to check the factorial value of
the given number.
PROGRAM :
<html>
<head>
<title>factorial calculation</title>
</head>
<body bgcolor=" orange">
<h2> FACTORIAL CALCULATION</h2>
<form name="fm" method="POST" action="<?php
$_PHP_SELF?>">
ENTER THE NUMBER : <input type="text" name="num">
<input type="submit" value="CHECK">
<input type="reset" value="CLEAR">
</form>
</body>
</html>
<?php
if(isset($_POST['num']))
$n=$_POST['num'];
$ans=fact($n);
echo " THE FACTORIAL VALUE IS : ".$ans;
function fact($n)
{
$f=1;
for($i=1;$i<=$n;$i++)
$f=$f*$i;
return $f;
}
?>
OUTPUT:
RESULT :
Thus the program was successfully completed.
Ex.No : 9
FIBONACCI SERIES
Date :
/ / 2025
AIM :
To write a PHP program to generate Fibonacci Series.
PROGRAM :
<html>
<head>
<title>Fibonacci Series</title>
</head>
<body bgcolor="pink">
<h2>Fibonacci Series</h2>
<form name="fm" method="POST" action="<?php
$_PHP_SELF?>">
Enter Any Number: <input type="text" name="num">
<br> <br>
<input type="submit" value="Accept">
<input type="reset" value="Clear">
</form>
</body>
</html>
<?php if(isset($_POST['num']))
{
$n=$_POST['num'];
$f1=-1;
$f2=1;
echo"Fibonacci series are :<br>";
for($i=0;$i<$n;$i++)
{
$f3=$f1+$f2;
$f1=$f2;
$f2=$f3;
echo'<br>'.$f3;
}
}
?>
OUTPUT :
RESULT :
Thus the program was successfully completed.
Ex.No : 10
MULTIPLICATION TABLE
Date :
/ / 2025
AIM :
To write a PHP program to display the Multilication
Table.
PROGRAM :
<html>
<head><title>multiplication table</title></head><pre>
<body bgcolor="orange">
<h2> MULTIPLICATION TABLE</h2>
<form name="fm"method="POST"action="<?php
$_PHP_SELF?>">
ENTER THE FIRST NUMBER :<input type="text"
name="num1"><br><br>
ENTER THE SECOND NUMBER :<input type="text"
name="num2"><br><br>
<input type="submit" value="CHECK">
<input type="reset"value="CLEAR">
</form>
</body>
</html>
<?php
if(isset($_POST['num1']) && isset($_POST['num2']))
{
$t=$_POST['num1'];
$n=$_POST['num2'];
echo" MULTIPLICATION TABLE<br>";
echo" ************** ***** <br>";
for($i=1;$i<=$n;$i++)
{
$f=$i*$t;
echo $i."*".$t."=".$f."<br>";
}
}
?>
OUTPUT:
RESULT :
Thus the program was successfully completed.
Ex.No : 11
PRIME NUMBER GENERATION
Date :
/ / 2025
AIM :
To write a PHP program to check the number is prime or
not.
PROGRAM :
<html>
<body bgcolor="orange"> <h2> PRIME NUMBER </h2>
<form method="POST">
Enter the number:
<input type="number" name="number"/><br><br>
<input type="submit" name="submit" value="Check">
</form>
</body>
</html>
<?php
if (isset($_POST['submit']))
{
$_num=$_POST['number'];
$_f=0;
$_i=2;
while($_i<=$_num/2)
{
if($_num % $_i==0)
{
$_f=1;
break;
}
$_i=$_i+1;
}
if($_f==1)
{
echo "Not prime";
}
else
echo "Prime";
}
?>
OUTPUT:
RESULT :
Thus the program was successfully completed.
Ex.No : 12
ARMSTRONG NUMBER CHECKING
Date :
/ / 2025
AIM :
To write a PHP program to check the given number is
Armstrong or not.
PROGRAM :
<html>
<body>
<form action="" method="post">
<br><center><h1><u>ARMSTRONG</u></h1></center>
<br><table bgcolor="Crimson" align="center">
<tr><td><br><input type="text" value=" Enter the
Input" readonly>
<input type="text" name="n"></tr></td>
<tr><td><br><br><center><br><br>
<input type="submit" value=" SUBMIT
">
<br><br><br></center></tr></td></table>
</form>
</body>
</html>
<?php
if($_POST)
{
$n1=$_POST["n"];
$m=$n1;
$s=0;
while($n1>0)
{
$r=$n1%10;
$n1=$n1/10;
$s=$s+($r*$r*$r);
}
echo '<font color="Crimson">';
if($m==$s)
echo"<h2> $m is Armstrong Number</h2>";
else
echo"<h2> $m is not Armstrong Number</h2>";
}
echo'</font>';
echo'</td></tr></table>';
?>
OUTPUT:
RESULT :
Thus the program was successfully completed.
Ex.No : 13
PALINDROME CHECKING
Date :
/ / 2025
AIM :
To write a PHP program to check the given number is
Palindrome or not.
PROGRAM :
html>
<head><title>palindrome or not</title></head>
<body bgcolor="PINK">
<h2> PALINDROME OR NOT</h2>
<form name="fm"method="POST"action"<?php$ PHP_SELF?>
<BR>ENTER THE NUMBER:<input type="text"
name="str"><br><br>
<input type="submit" value="CHECK">
<input type="reset" value="CLEAR">
</form>
</body>
</html>
<?php
{
if(isset($_POST['str']))
$s=$_POST['str'];
$rev=strrev($s);
echo'<br>THE REVERSED NUMBER IS :'.$rev.'<br>';
if($s==$rev)
echo"<span style='color:BLUE'>
yes! The given number is palindrome!</span>";
else
echo"<span style='color:blue'>
no! The given number is not palindrome!</span>";
}
?>
OUTPUT:
RESULT :
Thus the program was successfully completed.
Ex.No : 14
REVERSE THE NUMBER
Date :
/ / 2025
AIM :
To write a PHP program to reverse the number.
PROGRAM :
<html>
<body bgcolor="cyan">
<h2> REVERSE THE NUMBER</h2>
<form method="POST"><br>
Enter the Number: <input type="number" name="a"/>
<br><br>
<input type="submit" name="submit"
value="CHECK"> <br>
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
$x=$_POST['a'];
echo "The reverse of $x is : ";
while($x>1)
$z=$x%10;
$x=$x/10;
echo "$z";
?>
OUTPUT:
RESULT :
Thus the program was successfully completed.
Ex.No : 15
DATE AND TIME
Date :
/ / 2025
AIM :
To write a PHP program to display the date and
time.
PROGRAM :
<html>
<body bgcolor="PINK">
<h2> DATE AND TIME</h2>
</body>
</html>
<?php
echo date("Y/m/d");
echo date("l");
date_default_timezone_set("Asia/Calcutta");
echo date("h:i:sa");
?>
OUTPUT:
RESULT :
Thus the program was successfully completed
Ex.No : 16
CHESS BOARD
Date :
/ / 2025
AIM :
To write a PHP program to display the chess board.
PROGRAM :
<html>
<body bgcolor="cyan">
<h1> A CHESS BOARD </h1>
<table height="400px" width="400px" cellspacing="0px"
cellpadding="0px" border="3px">
<?php
for($row=1;$row<=8;$row++)
{
echo "<tr>";
for($col=1;$col<=8;$col++)
{
$total=$row+$col;
if(($total%2)==0)
{
echo "<td height='40px' width='40px'
bgcolor='#ffffff'></td>";
}
else
{
echo "<td height='40px' width='40px'
bgcolor='#000000'></td>";
}
}
echo "</tr>";
}
?>
</body>
</html>
OUTPUT:
RESULT :
Thus the program was successfully completed.