I T Practicals (PHP)
I T Practicals (PHP)
Practicals (Science)
PHP
Practical No:-1
Write a PHP program to check if a person is eligible to vote or not. The
program should include the following-
Minimum age required for vote is 18.
Use PHP functions.
Use Decision making statement.
age.html
<html>
<head>
<title>Information</title>
</head>
<body>
<form action="agechk.php" method="POST">
Enter Name<input type="text" name="t1"><br>
Enter Age <input type="text" name="t2"><br>
<input type="submit" name="send" >
</form></body></html>
agechk.php
<?php
function cal()
{
$x=$_POST["t1"];
$y=$_POST["t2"];
if($y>=18)
{
echo "Dear ".$x;
echo"<br>you are eligible to vote";
}
else
{
echo "you are not eligible to vote";
}
}
cal();
?>
1
Saket College Kalyan East I.T.Practicals (Science)
Practical No:-2
Write a PHP function to count the total number of vowels (a,e,i,o,u)
from the string. Accept a string by using HTML form.
vowelfrm.html
<html>
<head>
<title> count vowels in string</title>
</head>
<body><h1 align ="center">Count Vowels using String Functions</h1>
<form action="vowelchk.php" method="GET">
Enter string: <input type ="text", name="t1"><br>
<input type="submit" name="send">
</form>
</body>
</html>
vowelcheck.php
<?php
$str=$_GET["t1"];
$v=array('a','e','i','o','u','A','E','I','O','U');
$len=strlen($str);
$num=0;
for($i=0;$i<$len;$i++)
{
if(in_array($str[$i],$v))
{
$num++;
}
}
echo "Total no Vowels in the given string is";
echo $num;
?>
2
Saket College Kalyan East I.T.Practicals (Science)
Practical No:-3
Write a PHP program to save marks of English, Hindi, Marathi, Maths and
Information Technology in an array. Display marks of individual subject
along with total marks and percentage
marks.php
<? php
$a=array (60,78,74,85,96);
$t=0;
$x=0;
$c=count ($a);
for ($x=0;$x<$c;$x++)
{
echo"<br><br>Marks in subject.$a[$x]";
$t=$t+$a[$x];
}
$p=$t*100/500;
echo"<br><br>Total is :.$t";
echo"<br><br>Percentage is :.$p";
?>