100% found this document useful (1 vote)
361 views

PHP Assignment

This document contains 5 PHP programming assignments, including writing a script to display PHP version and configuration information, creating an HTML form to accept a username and display it, writing a browser detection script, adding a delay to a program's execution, and displaying a sorted list of countries and capitals from an array. The assignments provide the code solutions and output for each PHP script.

Uploaded by

sujal patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
361 views

PHP Assignment

This document contains 5 PHP programming assignments, including writing a script to display PHP version and configuration information, creating an HTML form to accept a username and display it, writing a browser detection script, adding a delay to a program's execution, and displaying a sorted list of countries and capitals from an array. The assignments provide the code solutions and output for each PHP script.

Uploaded by

sujal patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

En no 190160116103

A1

190160116014

Name: - Patel yash vishnubhai


Enrollment Number: - 190160116103
Batch: - 5th IT B1
Subject: - Web-Development

1
En no 190160116103

190160116014 A1

Assignment-1(PHP)
Q.1) Write a PHP script to get the PHP version and configuration
information.
Program:

<!DOCTYPE html> <html


lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php

phpinfo(); ?>

</body>
</html>
En no 190160116103
OUTPUT:-
190160116103 A1

Q.2) Create a simple HTML form and accept the username and display
the name through PHP echo statement.
Program:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="" method="POST">
<input type="text" name="name" id="name" placeholder="Username"><b r>
<input type="submit" value="submit">
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST["name"];

echo "$name";

}
?>
</body>
</html>

7
190160116103 A1

O
u
t
p
u
t

8
190160116103 A1

Q.3) Write a simple PHP browser detection script.


Program:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php echo "The browser version is" .

"<br>"; echo

$_SERVER['HTTP_USER_AGENT'];

?>
</body>
</html>

9
190160116103 A1

OUTPUT: -

Q.4) 4 Write a PHP script to delay the program execution for the given
number of seconds.
Program:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php echo "Before delay " .

date("H:i:s") . " <br> "; sleep(5); echo

"After delay " . date("H:i:s");

?>
</body>

10
190160116103 A1

</html>

OUTPUT: -

11
A1

190160116014

Q.5) Create a PHP script which displays the capital and country
name from an array. Sort the list by the name of the capital.
Program:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php echo "Before delay " .

date("H:i:s") . " <br> "; sleep(5);

echo "After delay " . date("H:i:s");

$country = array(
"India" => "Delhi",
"UK" => "London",
"Pakistan" => "Lahore",
"Afghanistan" => "Kabul",
"Japan" => "Tokoyo"
190160116014

You might also like