PHP PracticalSET2 KD
PHP PracticalSET2 KD
Practical : 1
AIM: Write PHP Script to demostrate assosiative array
<?php
$a=array("Name"=>"krish","Surname"=>"Patel","class"=>"C","batch"=>"2");
?>
Output:-
ENROLL NO : 22171341102
IOT CE-C-52
15 | P a g e
Practical Set 2 SUB: PHP
Practical : 2
AIM: Write PHP script for cheacking that given number is prime or
not using user-defined function
<?php
function primeorcomp($a)
else
primeorcomp(10);
primeorcomp(11);
?>
Output:-
ENROLL NO : 22171341102
IOT CE-C-52
16 | P a g e
Practical Set 2 SUB: PHP Practical
:
AIM: Write PHP script to swap two number using user-defined
function. (call by value and call by reference)
<?php
function cbv($n1,$n2)
$c=$n1;
$n1 = $n2;
$n2 = $c;
function cbr(&$n1,&$n2)
$c=$n1;
$n1 = $n2;
$n2 = $c;
?>
ENROLL NO : 22171341102
IOT CE-C-52
17 | P a g e
Practical Set 2 SUB: PHP
Output:-
ENROLL NO : 22171341102
IOT CE-C-52
18 | P a g e
Practical Set 2 SUB: PHP Practical
:
AIM: Write PHP script to demonstrate Variable function.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<?php
$a = 27;
$b = "Exlaso"; $bool
= true;
var_dump($a);
echo "<br>";
var_dump($b);
echo "<br>";
$a to String"; settype($a,
</body>
Output:-
ENROLL NO : 22171341102
IOT CE-C-52
19 | P a g e
Practical Set 2 SUB: PHP
5
AIM: Write PHP script to demonstrate String function.
ENROLL NO : 22171341102
IOT CE-C-52
20 | P a g e
Practical Set 2 SUB: PHP Practical
:
<?php echo"<b>CHR string
echo strcmp("krish","krish");
strcmp("kp","knp"); echo"<br>";
echo strlen("krish");
university"); echo"<br>";
ENROLL NO : 22171341102
IOT CE-C-52
21 | P a g e
Practical Set 2 SUB: PHP
patel");
trim("hello","0"); echo
"<br>";
?>
Output:-
ENROLL NO : 22171341102
IOT CE-C-52
22 | P a g e
Practical Set 2 SUB: PHP Practical
:
6
AIM: Write PHP script to demonstrate Date function.
<?php
("d/m/Y")."<br>"; var_dump
time();
?>
Output:-
ENROLL NO : 22171341102
IOT CE-C-52
23 | P a g e
Practical Set 2 SUB: PHP
Practical : 7
AIM: Write PHP script to demonstrate Math function.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body> <?php
echo pow(20,3);
sqrt(144); echo
'</br>'; echo
round(30.23); echo
12.29)
?>
</body>
</html>
Output:-
ENROLL NO : 22171341102
IOT CE-C-52
24 | P a g e
Practical Set 2 SUB: PHP
Practical : 8
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<?php
$arr = array("K","R","I","S","H");
$arr1 = $arr;
as $a){
$a;
ENROLL NO : 22171341102
IOT CE-C-52
25 | P a g e
Practical Set 2 SUB: PHP
echo "</br>";
$arr3 = array_merge($arr1,$arr2);
$value";
?>
</body>
</html>
Output:-
ENROLL NO : 22171341102
IOT CE-C-52
26 | P a g e
Practical Set 2 SUB: PHP
Practical : 9
AIM: Write PHP script to demonstrate File function.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<?php
$arr = file("krish.txt");
"<hr>";
?>
</body>
</html>
ENROLL NO : 22171341102
IOT CE-C-52
27 | P a g e
Practical Set 2 SUB: PHP
krish.txt :- name :
C - 52
E.no : 22171341103
SUB : PHP
ENROLL NO : 22171341102
IOT CE-C-52
28 | P a g e