Professional Documents
Culture Documents
8 TH
8 TH
8 TH
<?php
$dayOfWeek = date('l');
$colors = [
];
if (array_key_exists($dayOfWeek, $colors)) {
$bg = $colors[$dayOfWeek];
9th
html>
<body>
<form>
</form>
</body>
<?php
$n = $_GET['prime'];
for($i=2;$i<=$n;$i++){
$b=0;
for($j=2;$j<$i;$j++){
if($i%$j==0){
$b=1;
break;
if($b==0){
echo "$i" ;
echo "<br>";
}
} ?>
</html>
B)
<html>
<body>
<form >
<input type="submit">
</form>
</body>
<?php
$n = $_GET['fib'];
$a=0;
$b=1;
echo $a;
echo "<br>";
echo $b ;
echo "<br>";
for($i=3;$i<=$n;$i++){
$c = $a+$b ;
echo $c ;
echo "<br>";
$a = $b;
$b=$c;
?>
</html>
10th)
<!DOCTYPE html>
<html>
<body>
<form method="post">
</form>
<?php
$myarray=$_POST["no"];
$mya=explode(" ",$myarray);
sort($mya);
print_r(array_unique($mya));
?>
</body>
</html>
11th)
<?php
echo "*";
echo "<br>";
?>
12th)
<?php
$a = [
];
function search($data,$criteria,$value) {
$result=[];
foreach($data as $item)
if($item[$criteria]==$value){
$result[]=$item;
return $result ;
$x= search($a,'age','25');
if(count($x)>0){
foreach($x as $v){
echo $v['id'];
echo "<br>";
echo $v['name'];
echo "<br>";
echo $v['age'];
echo "<br>";
?>
15th)
<html>
<head>
</head>
<body>
<form method="post">
</textarea>
</form>
<?php
$x=$_POST['content'];
fwrite($myfile,$x);
fclose($myfile);
fclose($myfile);
?>
</body>
</html>
17th)
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<?php
$name = test_input($_POST["name"]);
$email = test_input($_POST["email"]);
$website = test_input($_POST["website"]);
function test_input($data) {
$data = trim($data); // trimes the spaces before and after the string
$data = stripslashes($data); // if the text containes forward slash that is \\\ it removes it
return $data;
?>
<form method="post">
</form>
<?php
echo $name;
echo "<br>";
echo $email;
echo "<br>";
echo $website;
?>
</body>
</html>
18th)
<?php
$cookie_name = "user";
if(!isset($_COOKIE[$cookie_name])) {
} else {
?>
20 A)
<?php
try {
$a = 10;
$b = 0;
if ($b !== 0) {
$c = $a % $b;
echo $c;
} else {
echo $e->getMessage();
?>
B)
<?php
try {
?>