PHP
PHP
<body>
<h1>Person is Eligible or not for voting</h1>
<form method="post" action="age.php">
<div>
Enter Voter Age: <input type="text" name="t1"><br>
<input type="submit" name="submit" value="Check Voter Age">
</div>
</form>
</body>
</html>
<?php
function chkvotag()
{
$age=$_POST['t1'];
if($age>=18)
{
echo "Candidate is eligible";
}
else
{
echo "Candidate is not eligible";
}
}
if(isset($_POST['submit']))
{
chkvotag();
}
?>
<?php
if(isset($_POST['submit_1']))
{
$str=strtolower($_POST['string']);
$vowels=array('a','e', 'i', 'o', 'u');
$len=strlen($str);
$num=0;
for($i=0;$i<$len;$i++)
{
if(in_array($str[$i],$vowels))
{
$num++;
}
}
echo "Number of vowels:, $num";
}
?>
<html>
<body>
<h1 align="center">string function</h1>
<form method="post" action="vowel.php">
Enter string
<input type="text" name="string"><br><br>
<input type="submit" name="submit_1" value="count Vowels">
</form>
</body>
</html>
<html>
<body>
<h1>Student Mark Array Element </h1>
<?php
$e=array(90,56,78,98);
$tot=0;
$avg=0;
$c=count($e);
for($i=0;$i<$c;$i++)
{
echo"<br><br>Subject Mark =".$e[$i];
$tot=$tot+$e[$i];
}
$avg=$tot/5;
echo"<br><br>Total Mark =".$tot;
echo"<br><br>Average Mark =".$avg;
?>
</body>
</html>