PHP SOP
SKILL ORIENTED PRACTICAL NUMBER: 06
Aim:
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>Check Person
Age</title></head>
<body>
<h1 align="Center">To Check
age of person to eligible to vote or not</h1>
<form method="post"
action="age.php">
Enter
the person age:
<input type="text"
name="txtage"> <br><br>
<input type="submit"
name="btnsubmit" value="Check Eligible">
<br><br>
</form>
</body>
</html>
“age.php”
<?php
if(isset($_POST['btnsubmit']))
{
$age=$_POST['txtage'];
if($age>=18)
echo"<b><br>YOU ARE
ELIGIBLE TO VOTE!!";
else
echo"<b><br>YOU ARE
NOT ELIGIBLE TO VOTE!!";
?>
SKILL ORIENTED PRACTICAL NUMBER: 07
Create
event driven JavaScript program for the following .make use of appropriate
variable, JavaScript inbuilt string functions and control structure.
Ø To
accept string from user and count number of vowels in the given string.
vowels.php
<!DOCTYPE html>
<html>
<head><title>PHP
PROGRAM</title>
</head>
<h1>Find Number Total Number of Vowels in a String</h1>
<form action=""
method="post">
The
String :<input type="text" name="txtstr" >
<input type="submit"
name="btnsubmit" value="submit">
</form>
<?php
if($_POST)
{
$str = strtolower($_POST['txtstr']);
$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 total vowels :
".$num;
}
?>
</body>
</html>
OUTPUT
:
SOP3: Write a PHP Program to Perform the following
Operations On an
Associative
array.
Ø Display elements of
an array along with their keys.
Ø Display the Size of
an array.
Ø Delete an element
from an array from the given index.
<?php
$m1 =array("English"=>"65",
"Hindi"=>"85",
"Math"=>"45",
"Marathi"=>"75");
echo "<br><br><b>Elements of an array along with
their keys : </ b >";
echo "<br> <br> Your score ".$m1['English']. "
in English";
echo "<br> <br> Your score ".$m1['Hindi']. " in
Hindi";
echo "<br> <br> Your score ".$m1['Math']." in
Maths";
echo "<br> <br> Your score ".$m1['Marathi']." in
Marathi";
echo "<br><br><b>Size of an array is
:</b>".count($m1);
array_splice($m1,1,1);
echo "<br><br><b>After deleting array is </ b
>";
foreach($m1 as $x =>$x_value)
{
echo "<br><br>Key=".$x.", Value=".$x_value;
echo "<br>";
}
?>
OUTPUT:



Comments
Post a Comment