0% found this document useful (0 votes)
14 views14 pages

Swami Rama Himalayan Univesity Hill Campus Toli Dudharkhal: Program Name: Batch: Session: Couse Name: Course Code

This document outlines the course details for a Web Development using PHP Lab at Swami Rama Himalayan University for the B.C.A program, batch 2022-25. It includes a list of programming assignments with objectives and corresponding PHP scripts for various tasks such as retrieving PHP configuration, creating forms, and validating emails. The document serves as a guide for students to complete their lab exercises and showcases practical applications of PHP programming.

Uploaded by

Gaurav singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views14 pages

Swami Rama Himalayan Univesity Hill Campus Toli Dudharkhal: Program Name: Batch: Session: Couse Name: Course Code

This document outlines the course details for a Web Development using PHP Lab at Swami Rama Himalayan University for the B.C.A program, batch 2022-25. It includes a list of programming assignments with objectives and corresponding PHP scripts for various tasks such as retrieving PHP configuration, creating forms, and validating emails. The document serves as a guide for students to complete their lab exercises and showcases practical applications of PHP programming.

Uploaded by

Gaurav singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

SWAMI RAMA HIMALAYAN UNIVESITY HILL CAMPUS

TOLI DUDHARKHAL

PROGRAM NAME: - B.C.A


BATCH: - 2022-25
SESSION: - 2024-25
COUSE NAME: - WEB DEVELOPMENT USING PHP LAB
COURSE CODE: - BCP306

SUBMITTED TO: - SUBMITTED BY: -


MR. SHIVPREET GAURAV
ASSISTANT PROFESSOR REG. NO.: - PG22111301005
C.S DEPARTMENT ENROLL. NO.: - SRHU22000680
INDEX
PAGE
[Link] OBJECTIVE DATE
NO.
WAP TO GET THE PHP VERSION AND CONFIGURATION INFO.
1. 1-2

CREATE A SIMPLE HTML FORM AND ACCEPT THE USER NAME


2.
AND DISPLAY THE NAME THROUG PHP ECHO STATEMENT
3. WRITE A PHP SCRIPT TO GET THE CLIENT IP ADDRESS

4. WRITE A SIMPLE PHP BROWSER DETECTION SCRIPT 15-16 26/10/23

5. WRITE A PHP SCRIP TO GET THE CURRENT FILE NAME 17-18 03/10/23
WRITE A PHP SCRIPT, WHICH WILL RETURN THE FOLLOWOING
6. 19-20 09/10/23
COMPONENTS OF THE URL ‘HTTP://[Link]’.
WRITE A PHP SCRIPT WHICH CHANGES THE COLOR OF THE FIRST
7. 21-22 10/10/23
CHARACTER OF A WORD.
WRITE A PHP SCRIPT TO CHECK WHTHER THE PAGE IS CALLED
8. 23-24 16/10/23
FROM HTTPS OT HTTP.
9. WRITE A PHP SCRIPT TO REDIRECT A USER TO A DIFFERENT PAGE.

10. WRITE A SIMPLE PHP PROGRAM IN CHECK THAT EMAILS ARE VALID 33-34 31/10/23

11. WRITE A PHP SCRIPT TO DISPLAY STRING VALUES WITHIN A TABLE. 35-36 06/11/23
1. WAP to get the PHP version and configuration info

<?php

phpinfo();

?>
2. Create a simple HTML form and accept the user name and display the name through
PHP echo statement

html

<!-- [Link] -->

<form method="POST" action="[Link]">

Enter your name: <input type="text" name="name">

<input type="submit">

</form>

//php

<!-- [Link] -->

<?php

echo "Welcome " . $_POST["name"];

?>

output

Welcome Gaurav
3. Write a PHP script to get the client IP address

<?php

$ip = $_SERVER['REMOTE_ADDR'];

echo "Client IP Address is: " . $ip;

?>

Output:

Client IP Address is: [Link]


4. Write a simple PHP browser detection script

<?php

echo "You are using: " . $_SERVER['HTTP_USER_AGENT'];

?>

Output:

You are using: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ...
5. Write a PHP script to get the current file name

<?php

echo "Current file name: " . basename(__FILE__);

?>

Output:

Current file name: [Link]


6. Write a PHP script to return components of the URL ‘[Link]

<?php

$url = '[Link]

$parts = parse_url($url);

echo "Scheme: " . $parts['scheme'] . "<br>";

echo "Host: " . $parts['host'];

?>

Output:

Scheme: http

Host: [Link]
7. Write a PHP script which changes the color of the first character of a word

<?php

$word = "University";

$first = substr($word, 0, 1);

$rest = substr($word, 1);

echo "<span style='color:red;'>$first</span>$rest";

?>

Output:
The letter U will appear in red:

html

<span style='color:red;'>U</span>niversity
8. Write a PHP script to check whether the page is called from HTTPS or HTTP

<?php

if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') {

echo "Connection is HTTPS";

} else {

echo "Connection is HTTP";

?>

Output:

Connection is HTTP
9. Write a PHP script to redirect a user to a different page

<?php

header("Location: [Link]

exit();

?>

Output:
Redirects to [Link]
10. Write a simple PHP program to check that emails are valid

<?php

$email = "example@[Link]";

if (filter_var($email, FILTER_VALIDATE_EMAIL)) {

echo "$email is a valid email address";

} else {

echo "$email is not a valid email address";

?>

Output:

example@[Link] is a valid email address


11. Write a PHP script to display string values within a table

<?php

$data = array("Gaurav", "Neha", "Ravi");

echo "<table border='1'>";

echo "<tr><th>Name</th></tr>";

foreach ($data as $name) {

echo "<tr><td>$name</td></tr>";

echo "</table>";

?>

Output:

Name

Gaurav

Neha

Ravi

You might also like