0% found this document useful (0 votes)
803 views3 pages

I T Practicals (PHP)

The document contains descriptions of 3 PHP practical exercises: 1) A program to check if a person is eligible to vote based on their age entered in a form. It uses a function and if/else statement. 2) A program to count the number of vowels in a string entered in a form, using an array of vowels and a for loop. 3) A program to store marks of 5 subjects in an array, display each mark and calculate the total and percentage. It uses a for loop to iterate through the array.

Uploaded by

vector1march
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
803 views3 pages

I T Practicals (PHP)

The document contains descriptions of 3 PHP practical exercises: 1) A program to check if a person is eligible to vote based on their age entered in a form. It uses a function and if/else statement. 2) A program to count the number of vowels in a string entered in a form, using an array of vowels and a for loop. 3) A program to store marks of 5 subjects in an array, display each mark and calculate the total and percentage. It uses a for loop to iterate through the array.

Uploaded by

vector1march
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Saket College Kalyan East I.T.

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 &nbsp;".$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";
?>

You might also like