Lab Manual 06 (MAD)
Lab Manual 06 (MAD)
Lab (MAD)
Code: CP-405L
Lab 6: PHP
Sr. CO CO CO CO CO
Title of the Practical
No. a. b. c. d. e.
I Practical Significance:
PHP is popular scripting language, which is used to develop various web applications.
PHP is also object oriented programming language students will be able to setup
PHP environment for executing PHP program or using different server like WAMP or
XAMPP server.
II Relevant Program Outcomes (POs)
2
VI Relevant Affective domain related Outcome(s)
Step1:
Step2:
Click XAMPP for Windows. It's a grey button near the bottom of the page. Depending on your
browser, you may first have to select a save location or verify the download.
3
Step3:
Double-click the downloaded file. This file should be named something like xampp-win32-7.2.4-
0-VC15-installer, and you'll find it in the default downloads location (e.g., the "Downloads"
folder or the desktop).
Step 4
Click Yes when prompted. This will open the XAMPP setup window. You may have to click OK
on a warning if you have User Account Control (UAC) activated on your computer.
4
Step 5:
Click Next. It's at the bottom of the setup window.
Step 6:
Select aspects of XAMPP to install. Review the list of XAMPP attributes on the left side of the
window; if you see an attribute that you don't want to install as part of XAMPP, uncheck its box.
By default, all attributes are included in your XAMPP installation.
5
Step 8:
Select an installation location. Click the folder-shaped icon to the right of the current installation
destination, then click a folder on your computer. If you have the UAC activated on your
computer, avoid installing XAMPP in your hard drive's folder (e.g., OS (C:)). You can select a
folder (e.g., Desktop) and then click Make New Folder to create a new folder and select it as the
installation destination.
Step 9: Click OK. Doing so confirms your selected folder as your XAMPP installation location.
6
Step11:
Uncheck the "Learn more about Bitnami" box, then click Next. The "Learn more about Bitnami"
box is in the middle of the page.
Step 12:
Begin installing XAMPP. Click Next at the bottom of the window to do so. XAMPP will begin
installing its files into the folder that you selected.
Step 13:
Click Finish when prompted. It's at the bottom of the XAMPP window. Doing so will close the
window and open the XAMPP Control Panel, which is where you'll access your servers.
7
Step 14:
Select a language. Check the box next to the American flag for English, or check the box next
to the German flag for German.
Step 15:
Click Save. Doing so opens the main Control Panel page.
Step 16: Start XAMPP from its installation point. If you need to open the XAMPP Control Panel
in the future, you can do so by opening the folder in which you installed XAMPP, right-clicking
the orange-and-white xampp-control icon, clicking Run as administrator, and clicking Yes when
prompted. When you do this, you'll see red X marks to the left of each server type (e.g.,
"Apache"). Clicking one of these will prompt you to click Yes if you want to install the server
type's software on your computer.
Counter intuitively, double-clicking the xampp_start icon doesn't start XAMPP.
8
Step 17:
Resolve issues with Apache refusing to run. On some Windows 10 computers, Apache won't run
due to a "blocked port". This can happen for a couple of reasons, but there's a relatively easy fix:
Click Config to the right of the "Apache" heading.
Click Apache (httpd.conf) in the menu.
Scroll down to the "Listen 80" section (you can press Ctrl+F and type in listen 80 to find it
faster).
Replace 80 with any open port (e.g., 81 or 9080).
Press Ctrl+S to save the changes, then exit the text editor.
Restart XAMPP by clicking Quit and then re-opening it in administrator mode from its folder.
9
Step 18:
Click on Start button of (Apache Server, PHP, and MySql). Now Web server is ready to execute
PHP and MySql program.
Program:
<?php
?>
Output screen:
10
C: Write a simple PHP program using expressions and
11
PHP Increment / Decrement Operators
Operator Name Description
++$x Pre-increment Increments $x by one, then returns $x
$x++ Post-increment Returns $x, then increments $x by one
- -$x Pre-decrement Decrements $x by one, then returns $x
$x-- Post-decrement Returns $x, then decrements $x by one
<= Less than or equal $x <= $y Returns true if $x is less than or equal to $y
to
<html>
<body>
<center>
<h1>
<b>
<?php
$x = 10;
$y = 6;
echo("<br>Addition is ".($x +
$y));
?>
</b>
</h1>
</body>
</html>
Output Screen.
14
VII. Resources Required:
Name of
Sr. no.
Resources Suggested Broad Specification Quantity Remark
Hardware: Computer (i3-i5 preferable), RAM
1 Computer minimum 2 GB and onwards
System As per batch For all
Operating Windows/ Linux size Experiments
2
System
3 Software PHP 7.3.12 or above
Note: Below given are few sample questions for reference. Teacher must design more such questions
so as to ensure the achievement of identified CO.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
15
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Lab Tasks
3. Write a various comparison operators in PHP with example.
4. Write a various Logical operators in PHP with example.
16
XI. References/ Suggestions for Futher Reading.
1. https://www.w3schools.com/php/default.asp
2. https://www.guru99.com/what-is-php-program.html
3. https://www.tutorialspoint.com/php/
4. https://tutorialehtml.com/en/php-tutorial-introduction/
5. www.tizag.com/phpT/
6. https://books.goalkicker.com/PHPBook/
7. https://codecourse.com/watch/php-basics
17
Write a PHP program to demonstrate the use of Decision making control structures using-
a. If statement
b. If-else statement
c. Switch statement
I Practical Significance:
In computer science, conditional statements, expressions and constructs are perform different
computations or actions depending on whether Boolean condition evaluates to true or false.
Students will be able to use various forms of if statements to check the condition.
II Relevant Program Outcomes (POs)
18
VI Relevant Affective domain related Outcome(s)
Controls statements are used to control are used to control the flow of execution of program based on
certain conditions. These are used to cause the flow of execution to advance and branch based on
changes to the state of program.
1. if statement
2. if-else statement
3. If..elseif..else statement
1. if: if statement is simple decision making statement. It is used to decide whether a certain statement
or block of statements will be executed or not. i.e. if a certain condition is true then the block will be
executed otherwise not.
Syntax:
if(condition)
2. if-else statement: The if statement alone tells us that if a condition is true it will execute a block
of statements and if the condition false, else block will be executed.
if( condition)
else
19
3. switch statement
The switch statement is used to perform different actions based on different conditions. Use the switch
statement to select one of many blocks of code to be executed.
switch(n)
{
case label1:
//code to be executed if n=label1;
break;
case label2:
//code to be executed if n=label2;
break;
case label3:
//code to be executed if n=label3;
break;
...
default:
//code to be executed if n is different from all labels;
}
Nill
20
X. Program Code: Teacher must assign a separate program statement to group of 3-4
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
21
XII. Practical Related Questions:
Note: Below given are few sample questions for reference. Teacher must design more such questions
so as to ensure the achievement of identified CO.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
22
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Tasks
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
23
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
24
XII. References/ Suggestions for Futher Reading.
1. https://www.w3schools.com/php/default.asp
2. https://www.guru99.com/what-is-php-program.html
3. https://www.tutorialspoint.com/php/
4. https://tutorialehtml.com/en/php-tutorial-introduction/
5. www.tizag.com/phpT/
6. https://books.goalkicker.com/PHPBook/
7. https://codecourse.com/watch/php-basics
25
Write a PHP program to demonstrate the use of Looping structures using-
a) While statement
b) Do-while statement
c) For statement
d) Foreach statement
I Practical Significance:
Loop is used in programming to repeat a specific block of code until certain condition is true.
Students will be able to use while and do-while loop to replace the repetition of statements.
II Relevant Program Outcomes (POs)
26
V Practical Outcome (PrOs) :
1. While loop
while (condition is true)
{
//code to be executed;
}
2. Do..While loop
do
//code to be executed;
3. For loop
for (init counter; test counter; increment counter)
{
//code to be executed for each iteration;
}
4.
VII. Resources Required
Nill
27
IX. Resources used:
X. Program Code: Teacher must assign a separate program statement to group of 3-4
students. Write a program to print first 30 even numbers. (Using for, while, do..while)
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
28
XI. Result ( Output of code )
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Note: Below given are few sample questions for reference. Teacher must design more such questions
so as to ensure the achievement of identified CO.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
29
XI. Exercise
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
30
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
1. https://www.w3schools.com/php/default.asp
2. https://www.guru99.com/what-is-php-program.html
3. https://www.tutorialspoint.com/php/
4. https://tutorialehtml.com/en/php-tutorial-introduction/
5. www.tizag.com/phpT/
6. https://books.goalkicker.com/PHPBook/
7. https://codecourse.com/watch/php-basics
31