6030 PHP
6030 PHP
Dinesh Kumar
Information Technology
242
Government Polytechnic
DTE’s Vision:
To provide globally competitive technical education;
Remove geographical imbalances and inconsistencies;
Develop student friendly resources with a special focus on girls’ education and support to
weaker sections;
Develop programs relevant to industry and create a vibrant pool of technical professionals.
Institute’s Vision:
Institute’s Mission:
Department’s Vision:
To acquire quality Education, Research and Development in the field of Information technology
meeting the global standards and comply with the ever-growing technology
Department’s Mission:
The graduates of our department will be efficient in technical and ethical responsibilities to
become globally recognised by pursuing opportunities for higher studies and real time problem
solving.
Students will be competent by learning the principals of Information technology that can match
national and international standards.
Dinesh Kumar.
236170316030
2024-2025
GP Ahmedabad
236170316030
Dinesh Kumar Even
12
19
22
26
29
31
33
37
39
42
44
45
Practical No. 1 : Environment setup, Configuration and Syntax
A. Install and configure PHP, Apache Web Server and database server
using XAMPP.
B. Write a PHP script to display Welcome message.
A. Install and configure PHP, Apache Web Server and database server
using XAMPP.
1. Download XAMPP: Go to the official Apache Friends website
(https://www.apachefriends.org/download.html) and download the
XAMPP installer for your operating system (Windows, Linux, or
macOS).
12 | Page
3. Select Components: In the "Select Components" step, ensure that at least
"Apache," "MySQL," and "PHP" are selected. You can also choose other
components like phpMyAdmin (for database management) if you wish.
13 | Page
5. Complete Installation: Continue through the wizard and complete the
installation.
14 | Page
6. Start XAMPP Control Panel: Once installed, open the XAMPP Control
Panel. You should find it in your Start Menu (Windows) or Applications
folder (macOS/Linux).
7. Start Apache and MySQL: In the XAMPP Control Panel, click the "Start"
buttons next to "Apache" and "MySQL." If they start successfully, you'll
see green indicators.
15 | Page
8. Testing Apache: Open your web browser and go to http://localhost or
http://127.0.0.1. If XAMPP is installed correctly, you should see the
XAMPP welcome page.
16 | Page
9. Testing PHP: Create a new file named info.php inside the htdocs folder
within your XAMPP installation directory (e.g., C:\xampp\htdocs). Add
the following PHP code to the file:
17 | Page
B. Write a PHP script to display Welcome message.
1. Create a PHP File: In the htdocs folder (e.g., C:\xampp\htdocs), create a
new file named welcome.php (or any name you prefer with a .php
extension).
2. Write the PHP Code: Add the following PHP code to the welcome.php
file:
Assessment-Rubrics
18 | Page
Practical No. 2 : Variables, Constant and Operators
A. Write a PHP script to demonstrate use of global, local, static variables
and constant.
B. Write a PHP script to demonstrate arithmetic operators, comparison
operator, and logical operator.
C. Write a PHP program to swap two numbers with and without using
third variable
• Input-Output :
19 | Page
B. Write a PHP script to demonstrate arithmetic operators, comparison
operator, and logical operator.
• Source code :
• Input-Output:
20 | Page
C. Write a PHP program to swap two numbers with and without using
third variable
• Source code :
• Input-Output:
Assessment-Rubrics
21 | Page
Practical No. 3 : Conditional Statements
A. Write a PHP script to check the given number is odd or even.
B. Write a PHP script to print student’s grade based on marks of 5
subjects.
C. Create a PHP script to show the month of a year using switch
statement.
• Input-Output :
22 | Page
• Source code :
• Input-Output:
23 | Page
C. Create a PHP script to show the month of a year using switch
statement.
• Source code :
• Output:
24 | Page
• Input-Output:
Assessment-Rubrics
25 | Page
Practical No. 4 : Looping Structures
A. Write PHP Script to print Fibonacci series in html tabular format.
B. Write a PHP script to print below number triangle.
26 | Page
• Input-Output:
• Source code:
• Input-Output:
27 | Page
C. Write a PHP script to create chess board (tabular structure).
• Source code:
• Input-Output:
Assessment-Rubrics
28 | Page
Practical No. 5 : Arrays
A. Write PHP Script for addition and multiplication of two 2x2 matrices.
B. Write a PHP Script to count the number of elements in an array without
using built-in function (use numeric and associative arrays).
A. Write PHP Script for addition and multiplication of two 2x2 matrices.
• Source code :
29 | Page
• Input-Output:
• Source code:
• Input-Output:
Assessment-Rubrics
30 | Page
Practical No. 6 : User defined Functions
A. Write a PHP script to call by reference and call by value.
B. Write a PHP Script for performing function that takes arguments with
default argument and returns value.
C. Write a PHP Script to show the use of variable length argument.
• Input-Output:
B. Write a PHP Script for performing function that takes arguments with
default argument and returns value.
• Source code :
31 | Page
• Input-Output:
• Input-Output:
Assessment-Rubrics
32 | Page
Practical No. 7 : Built-In functions
A. Write PHP script to demonstrate use of various strings handling
function.
B. Write a PHP script to Demonstrate Include() and require() function.
C. Write PHP script to demonstrate Array functions.
D. Write PHP script to demonstrate use of fopen(), fread(), fwrite() and
fclose() File functions.
• Input-Output:
33 | Page
• Source code:
• Input-Output:
34 | Page
• Source code: • Input-Output:
• Input-Output:
35 | Page
• Source code:
• Input-Output:
Assessment-Rubrics
36 | Page
Practical No. 8 : Form Handling
A. Create student registration form using text box, check box, radio
button, select, submit button. And display user inserted value in new
PHP page using GET or POST Method.
B. Write a PHP script to explain the concept of $_REQUEST.
A. Create student registration form using text box, check box, radio
button, select, submit button. And display user inserted value in new
PHP page using GET or POST Method.
• Source code :
display.php
37 | Page
• Input-Output:
Assessment-Rubrics
38 | Page
Practical No. 9 : Email and Validation
A. Write PHP script to validate form including name, email using
appropriate functions.
B. Write PHP script for sending plain text email, HTML email and
attachments with email.
A. Write PHP script to validate form including name, email using
appropriate functions.
• Source code :
• Input-Output:
B. Write PHP script for sending plain text email, HTML email and
attachments with email.
39 | Page
• Source code: (Sending Plain Text Email)
• Input-Output:
• Input-Output:
40 | Page
• Source code: (Sending Attachments With Email)
• Input-Output:
Assessment-Rubrics
41 | Page
Practical No. 10 : Session and Cookies
A. Write a PHP script to demonstrate creating, deleting, updating,
retrieving and passing variable cookie data.
B. Write PHP script to demonstrate passing information using Session.
• Input-Output:
42 | Page
• Source code: (Sending Attachments With Email)
• Input-Output:
Assessment-Rubrics
43 | Page
Practical No. 11 : Error Handling
A. Write a PHP script to demonstrate Error Handling.
• Input-Output:
Assessment-Rubrics
44 | Page
Practical No. 12 : Database
A. Write a PHP script to connect with database server from your webpage.
B. Create a database with student table and write a PHP script to insert a
record in student table.
C. Write a program to read student records from student table and display
all these information in table format on output screen.
D. Write a PHP script to delete and update a specific record from table.
E. Write a PHP script simple login system that allows user to add a new
username if user doesn’t exist in the database, also create a forgot
password link, to redirect user to set up his new password on
authentication.
A. Write a PHP script to connect with database server from your webpage.
• Source code :
• Input-Output:
B. Create a database with student table and write a PHP script to insert a
record in student table.
• Source code:
45 | Page
• Input-Output:
C. Write a program to read student records from student table and display
all these information in table format on output screen.
• Source code:
• Input-Output:
46 | Page
D. Write a PHP script to delete and update a specific record from table.
• Source code:
47 | Page
• Input-Output:
D. Write a PHP script simple login system that allows user to add a new
username if user doesn’t exist in the database, also create a forgot
password link, to redirect user to set up his new password on
authentication.
• Source code:
48 | Page
• Input-Output:
Assessment-Rubrics
49 | Page