PHP Mannual Final
PHP Mannual Final
AIM:
To write a Array function using php coding.
PROCEDURE:
Step 1: To open a notepad and write a html with php script coding.
Step 3: To check the String match and print the screen $result=array.diff($a1,$a2)
Step 7: To run program (To open and start the wamp server];
2)localhost/filename.php
<html>
<head>
<title>String manipulation</title>
</head>
<body>
<h1>array function<br>**********************<br>String
matching<br>*******************<br></h1>
<?php
$result=array_diff($a1,$a2);
print_r($result);
echo”<br>;
echo”**********************;
echo”<br>;
$cars=array(“c”,”php”,”java”,”c++”);
sort($cars);
$length=count($cars);
for($x=0;$x<$length;$x++)
Echo$cars[$x];
For($x=0;$x<$length;$x++)
echo$cars[$x];
Echo”<br>”;
echo”combination of string”;
echo”<br>”;
echo***********************”;
echo”<br>”;
$frame=array(“kiruthi”,”devi”,”viji”);
$age=array(“10”,”7”,”8”);
Echo”<br>”;
$c=array_combine($frame,$age);
print_r($c);
?>
</body>
</html>
OUTPUT:
RESULT:
Thus the above program is execute clearly and the output is verified.
EX NO: 2
FACTORIAL USING IF PAGE NO:
DATE: ELSE
AIM:
To write a java program to find factorial of a given number.
ALGORITHM:
Step 1: Start the program.
Step 4: Create a member function getdata() to print p and get the input number.
Step 5: Create another member function calfact() using to find factorial of a given number.
Step 6: In the member function calfact() using forloop for number of iteration and then print
the result.
Step 8: Using the object to call the member functions getdata() and calfact() to print the
result.
<head>
<title>Factorial number</title>
<body>
<h1>factorial number<br>
<h1>****************<br>
<form>
</form>
<?php
if(isset($_GET['n']))
$n=$_GET['n'];
$mult=1;
while($n>0)
$mult=$mult*$n;
$n=$n-1;
echo"result";
echo$mult;
?>
</body>
</html>
OUTPUT:
RESULT:
Thus the above program is executed clearly and the output is verified.
EX NO:3
INVENTORY CONTROL PAGE NO:
DATE:
AIM:
To display a inventory control using php coding.
PROCEDURE:
Step 1: To open the notepad and write a php script coding.
Step 2: To get the input value from user using text box in form.
$item=array(“m1”array(“fruit””apple””price””200”,”quantity””2kg”)
Itm $i;
If($i==$f)it is
true
}
PROGRAM:
<html>
<head>
<title>inventory control</title>
</head>
<body>
<form method=”POST”>
Type=”text”name=”name/>
<input
type=”submit”id=”submit”value=”submit”/>
</form>
<table border=‟5‟>
<?php>
$item=array(„m1”array(“fruit””apple”,”price””200”,”quantity””2kg”),”m2”array
(“vegetable””carrot”,”price””50”,”quntity””1kg”),);
$dataSetCount=count($item);
echo”<tr><td>”;
echo”<h1>therare$dataSetCount
items</h1>”;
echo”</td></tr>”;
$i=0;
Foreach($item as $each_item)
$i++;
echo”<tr><td>”;
echo”<h2>item$i</h2>”;
echo”</td></tr>”;
if($1==$f)
foreach($each_item as $key=>$val)
echo”<tr><td>”; echo”<b>$key</b>”.”/t”.
$val.”<br/>”; echo”</td></tr>”;
}
}
</table>
</body>
</html>
OUTPUT:
RESULT:
Thus the above program is executed clearly and the output is verified.
EX NO:4
STUDENT TABLE USING PAGE NO:
DATE: KEY AND VALUE
AIM:
To write a student mark list using php coding.
PROCEDURE:
Step 1: To Write a student mark list using php coding.
$rno=array(“21”array(“name””vijithiga”,”m1””38”.”m2””54”,”m3””8”,
”total””178”,”average””53.6”
roll no $i;
if ($i==$f)if it is true
Print $key$value
Step 7: To run the program(to open and start the wamp server).
<body>
<form method="post">
<input type="text"name="n1">
<input type="submit"value="submit">
</form>
<table border='5'>
<?php
$f=$_POST['n'];
<?php
$Rollno=array("u1"array("name""uma","m1""75","m2""90","m3""100","total"
"265","average""88.3"),"u2"array("name"”ani","m1""75","m2""65","m3""100
","total""240","average""88.3);"u3"array("name""sim","m1","m2""100","m3""
100","total""300","average""100"),);
$dataSetcount=count($Rollno);
echo"<tr><center></td>";
echo"<tr><td>";
echo"<n1><b>APC collage</b></h1>";
echo"</td></center></tr>";
echo"<tr><td>";
echo"</td></tr>;
$i=0;
$i++;
echo"<tr><td>";
echo"<h2>Rollno$1</h2>";
echo"</td></tr>;
if($i==$f)
echo"<tr><td>"; echo"<b>$key</b>"."/t".
$val."<br/>"; echo"</td></tr>";
?>
</table>
</body>
</html>
OUTPUT:
RESULT:
Thus the above program is executed clearly and the output is verified.
EX.NO:5
USER DEFINED FUNCTION PAGE NO:
DATE:
AIM:
To perform the user defined functions using php coding.
PROCEDURE:
Step 1: To open the notepad and write a html using php script coding.
Step 3: To perform the user defined functions such as function without input argument and
Step 4: Then print the result with above user defined functions.
$x=25;
$y=45;
$res=”Result.add($x).br();
echo”<b>$res</b>”
title3(“Addition of $x+$y”.br());
echo(“Result.add($x,$y).br());
echo(“Result”.add().br());
Function add($a=5,$b=10)
return $a+$b;
function title3($msg)
Echo”<h3>”.$msg.‟</h3>;
Function bo($msg)
Return”<br>”$msg”</b>”;
}
OUTPUT:
RESULT:
Thus the above program is executed clearly and the output is verified.
EX NO: 6
FACTORIAL USING RECURSION PAGE NO:
DATE:
AIM:
To find the factorial using recursion in php coding.
PROCEDURE:
Step 1: Start the program.
Step 4: Create a member function getdata() to print p and get the input number.
Step 5: Create another member function calfact() using to find factorial of a given number.
Step 6: In the member function calfact() using forloop for number of iteration and then
Step 8: Using the object to call the member functions getdata() and calfact() to print the
result.
<head>
<title>Factorial</title>
</head>
</body>
<form>
</form>
<?php
if(isset($_GET['n']));
$n1=$_GET['n'];
function Factorial($n1)
if($n1==0)
return 1;
else
return $n1*Factorial($n1-1);
}
}
?>
</html>
OUTPUT:
RESULT:
Thus the above program is executed clearly and the output is verified.
EX NO: 7
NCR USING FACTORIAL PAGE NO:
DATE:
AIM:
To find the NCR using factorial command in php coding.
PROCEDURE:
Step 1: To open a notepad and write a html using php script coding.
Function ncr($n,$r)
$c=text($n)/fact($r)*fact($n-$r);
Return $e;
Function fact($n1)
$f=1;
For($i=1,$ic=$n;$i++)
$f=$f*fi
;
Return f;
Step 7: To run the program(To open and start the wamp server];
2)localhost/filename.php
<head>ncr</head>
<title></title>
<body>
</body>
<form>
<input type="Submit"value="Check"/>
</form>
<?php
$n=$_GET['n'];
$r=$_GET['r'];
function ncr($n1,$r1)
$c=fact($n1)/(fact($r1)*fact($n1-$r1));
return $c;
function fact($n1)
$f=1;
for($i=1;$i<=$n1;$i++)
{
$f=$f*$i;
return $f;
echo ncr($n,$r);
?>
</body>
</html>
OUTPUT:
RESULT:
Thus the above program is executed clearly and the output was verified.
EX.NO:8
STRING MANIPULATION PAGE NO:
DATE:
AIM:
To display current date and time using php coding..
PROCEDURE:
Step 1: To open a notepad and write a html using php script
2)localhost/filename.php.
//seconds*minutes*hours*days+current time
$inTwoMonths=60*60*24*60+time();
Setcookie(„lastVisit‟,date(“G:i-m/d/y”),$inTwoMonths);
If(isset($_COOKIE[„lastVisit‟]))
$visit=$_COOKIE[„lastVisit‟];
else
?>
</body>
</html>
OUTPUT:
RESULT:
Thus the above program is executed clearly and the output is verified.
EX NO: 9
PERSONAL DETAIL FILE PAGE NO:
DATE:
AIM:
To process personal details using file in php coding.
PROCEDURE:
Step 1: To open a notepad and write php script coding.
<body>
<H1>Biodata</h1>
</form>
</body>
</html>
<?php
if ($_POST) {
echo "<h1>Biodata</h1>";
?>
OUTPUT:
RESULT:
Thus the above program was executed and the output was verified.
EX.NO:10 STUDENT MARK DATA
DATE: BASE PAGE NO:
USING HTML FORM
AIM:
To display student mark data in html using php coding.
PROCEDURE:
Step 1 : Open the notepad and write a html with php script coding.
<html>
<head>
</head>
<body>
<center>
<?php
// Check connection
. mysqli_connect_error());
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$mobile = $_REQUEST['mobile'];
$date = $_REQUEST['date'];
'$email','$mobile','$date')";
if(mysqli_query($conn, $sql)){
. "$mobile\n $date");
} else{
. mysqli_error($conn);
// Close connection
mysqli_close($conn);
?>
</center>
</body>
</html>
OUTPUT:
RESULT:
Thus the above program is executed clearly and the output verified.