Nidhi Mishra
Nidhi Mishra
Nidhi Mishra
NIDHI
MISHRA
Introduction to PHP:-
URL Open.
Server Must Be ON.
URL Address:- 127.0.0.1/folder name/file name
or
local host/folder name/filename
PHP Scripts:-
“ ”
‘ ’
;
“ ‘ ’ ”
‘ “ ” ’
Note:- If we want embed another
language, like HTML in PHP then all
HTML works as a string.
PHP echo and print statements:-
<?php Output:-
$t = date("H");
if ($t < "10") { Have a good day!
echo "HII!";
} elseif ($t < "20") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
The PHP Switch Statement:-
“Use the switch statement to select one of many blocks of code to be executed”.
Example:-
?php
$color = "red"; Output:-
switch ($color) {
case "red": Your color is red!
echo "Your color is red!";
break;
case "blue":
echo "Your color is blue!";
break;
case "green":
echo "Your color is green!";
break;
default:
echo "Your color is neither red, blue, nor green!";
}
?>
How To Get Form Value:-
strupper
strlower
strrev
strlen
substr
Example of strings:-
<?php Output:-
$a=“rcew”;
echo strupper($c); RCEW
echo strlowerer($c); rcew
echo strrev($c); wecr
echo strlen($c); 4
?>
Example of substring:-
<?php
$a=7062033739;
echo“xxxxxxx”.substr($a,7,3);
?>
Output:-
xxxxxxx739
PHP function:-
<?php Output:-
$arrr=array(4,9,80,95, 600
300,1,600);
echo max($arrr);
?>
Example of min:-
<?php Output:-
$arrr=array(4,9,80,95, 1
300,1,600);
echo min($arrr);
?>
Example of sum:-
<?php Output:-
$arrr=array(4,9,80, 1089
95,300,1,600);
echo array
sum($arrr);
?>
Example of product:-
<?php Output:-
$arrr=array(4,9,80,
95,300,1,600); 49248000000
echo
array_product($arr
r);
?>
Example of merge:-
<?php Output:-
$arrr=array(4,9,80,95,300 4
,1,600); 9
$arr=array(7,9,34,86,986,) 80
; 95
$ar=array_merge($arrr,$ 300
arr); 1
600
foreach($ar as $d) 7
{ 9
echo $d."<br>"; 34
} 86
?> 986
Example of sort:-
<?php Output:-
$arrr=array(4,9,80,95, 1
300,1,600); 4
sort($arrr); 9
foreach($arrr as $n) 80
95
{ 300
echo $n."<br>"; 600
}
?>
Example of rsort:-
<?php Output:-
$arrr=array(4,9,80,95, 600
300,1,600); 300
rsort($arrr); 95
foreach($arrr as $d) 80
9
{ 4
echo $d."<br>"; 1
}
?>
Example of array_pop:-
<?php Output:-
$arrr=array(4,9,80,95, 4
300,1,600); 9
array_pop($arrr); 80
foreach($arrr as $d) 95
300
{ 1
echo $d."<br>";
}
?>
Example of array_push:-
<?php Output:-
$arrr=array(4,9,80,95, 4
300,1,600); 9
array_push($arrr,111,1 80
21); 95
300
foreach($arrr as $d)
1
{ 600
echo $d."<br>"; 111
} 121
?>
Example of array_shift:-
<?php Output:-
$arrr=array(4,9,80,95, 9
300,1,600); 80
array_shift($arrr); 95
foreach($arrr as $d) 300
1
{ 600
echo $d."<br>";
}
?>
Example of array_unshift:-
<?php Output:-
$arrr=array(4,9,80,95, 0
300,1,600); 131
array_unshift($arrr,00 4
,131); 9
foreach($arrr as $d) 80
95
{ 300
echo $d."<br>"; 1
} 600
?>
<?php Output:-