Web - Based - Application - Development - Using - PHP Manual Print
Web - Based - Application - Development - Using - PHP Manual Print
(22619)
Semester –VI
Maharashtra State
Board of Technical Education, Mumbai
(Autonomous) (ISO 9001 : 2015) (lSO/IEC 27001 : 2013)
Maharashtra State Board of Technical
Education, (Autonomous) (ISO 9001 : 2008)
(lSO/IEC 27001 : 2005)
4th Floor, Government Polytechnic Building, 49, Kherwadi, Bandra ( East ), Mumbai
400051.
(Printed on June, 2019)
MAHARASHTRA STATE
BOARD OF TECHNICAL EDUCATION
Certificate
This is to certify that Mr. / Ms:………………………………...................................
…………………..……………………………………………………… of Institute
………………………………………………………………………………………
Course Outcomes(COs)
a. Develop program using control statement
b. Perform operation based on arrays and graphics
c. Develop programs by applying various object oriented concepts.
d. Use form controls with validation to collect user's input.
e. Perform database operations in PHP.
Sr. CO CO CO CO CO
Title of the Practical
No. a. b. c. d. e.
a. Install and configure PHP, web server, MYSQL
01 b. Write a program to print “Welcome to PHP” √
c. Write a simple PHP program using expressions and operators.
Write a PHP program to demonstrate the use of Decision making
control structures using-
02 a. If statement √
b. If-else statement
c. Switch statement
Write a PHP program to demonstrate the use of Looping structures
using-
a) While statement
03 b) Do-while statement √
c) For statement
d) Foreach statement
Write a PHP program for creating and manipulating-
a) Indexed array
04 √
b) Associative array
c) Multidimensional array
A. Write a PHP program to-
• Calculate length of string.
05 • Count the number of words in string without using string functions. √
B. Write a simple PHP program to demonstrate use of various built-in
string functions.
Write a simple PHP program to demonstrate use of simple function
06 and parameterized function. √
17
Write a PHP program to demonstrate
the use of Decision making control
structures using-
a. If statement
b. If-else statement
2 c. Switch statement
Write a PHP program to demonstrate 25
the use of Looping structures using-
a) While statement
b) Do-while statement
c) For statement
d) Foreach statement
3
Write a PHP program for creating 32
and manipulating-
a) Indexed array
b) Associative array
4 c) Multidimensional array
Sr Assess Dated
Date of Date of
. Page ment Sign. Remark
Title of The Pratical Performan Submissio Of
N No. Marks
ce n teache
o. (25)
r
Write a PHP program to
a) Inherit members of super class in
subclass. 61
8
b) Create constructor to initialize
object of class by using object
oriented concepts.
Write a simple PHP program on
9 70
Introspection and Serialization.
Design a web page using following 79
form controls:
10
a. Text box, b. Radio button,
c. Check box, d. Buttons
Design a web page using following 87
11 form controls:
a. List Box, b. Combo Box c.
Hidden field box
Develop web page with data 96
12
validation.
Write simple PHP program to - 102
13 a. Set cookies and read it.
b. Demonstrate session management
Write a PHP program for sending 111
14 and receiving plain text message (e-
mail).
Develop a simple application to - 118
a) Enter data into database
15
b) Retrieve and present data from
database
Develop a simple application to 127
16 Update, Delete table data from
database.
Total Marks
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)
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.
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.
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.
Step 9: Click OK. Doing so confirms your selected folder as your XAMPP installation location.
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.
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.
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.
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
?>
Operators in PHP
!== Not identical $x !== $y Returns true if $x is not equal to $y, or they
are not of the same type
<= 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;
?>
</b>
</h1>
</body>
</html>
Output Screen.
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.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XI. Exercise
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
Practical No: 02
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)
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
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
X. Program Code: Teacher must assign a separate program statement to group of 3-4 students.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Note: Below given are few sample questions for reference. Teacher must design more such questions
so as to ensure the achievement of identified CO.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XI. Exercise
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
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
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)
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
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)
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Note: Below given are few sample questions for reference. Teacher must design more such questions
so as to ensure the achievement of identified CO.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XI. Exercise
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
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
I Practical Significance:
Array in PHP is a type of data structure that allows us to store multiple elements of similar data
types under a single variable thereby saving us the effort of creating a different variable for every data.
Indexed or Numeric Arrays: An array with a numeric index where values are stored linearly.
Associative Arrays: An array with a string index where instead of linear storage, each value can be
assigned a specific key.
Multidimensional Arrays: An array which contains single or multiple array within it and can be
accessed via multiple indices.
These type of arrays can be used to store any type of elements, but an index is always a number. By
default, the index starts at zero.
$cars = array(“Volvo”,”BMW”,”Toyota”);
OR
$cars[0] = “Volvo”;
$cars[1] = “BMW”;
$cars[2] = “Toyota”;
The following example creates an indexed array name $cars, assigns three elements to it, and then
prints a text containing the array values:
<?php
$cars= array("Volvo", "BMW", "Toyota");
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
?>
<?php
$cars= array("Volvo", "BMW", "Toyota");
$arrlength=count($cars);
for($x= 0;$x<$arrlength;$x++)
{
echo $cars[$x];
echo "<br>";
}
?>
Associative arrays:
Associative arrays are arrays that use named keys that you assign to them.
OR
$total[‘fyif’]= “58”;
$total[‘syif’]= “61”;
$total[‘tyif’]= “46”;
<html>
<body>
<?php
?>
</body>
</html>
To loop through and print all the values of an associative array, you could use a foreach loop, like
this:
<html>
<body>
<?php
echo "<br>";
?>
</body>
</html>
Example:
$student = array
array("xyz",3401,86.45),
array("abc",3402,87.42),
array("pqr",3403,85.43),
);
<body>
<?php
$student = array
array("XYZ",3401,86.45),
array("ABC",3402,87.42),
array("PQR",3403,85.43),
);
?>
</body>
</html>
We can also put a for loop inside another for loop to get the elements of the $student
array:
<html>
<body>
<?php
$student = array
array("PQR",3402,87.42),
array("ABC",3403,85.43),
);
echo "<ul>";
echo "<li>".$student[$row][$col]."</li>";
echo "</ul>";
?>
</body>
</html>
Nill
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Note: Below given are few sample questions for reference. Teacher must design more such questions
so as to ensure the achievement of identified CO.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
……………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XI. Exercise
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
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
XIII. Assessment Scheme
Practical No: 05
String is a sequence of characters. Students will be able to perform various operations on String using
different methods.
Sr.
PHP function Use Example
No.
The PHP strlen() function returns the length of a
1 strlen() echo strlen("Hello world!");
string.
The PHP str_word_count() function counts the echo str_word_count("Hello
2 str_word_count()
number of words in a string. world!");
3 strrev() The PHP strrev() function reverses a string. echo strrev("Hello world!");
Nill
X. Program Code: Teacher must assign a separate program statement to group of 3-4 students.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Note: Below given are few sample questions for reference. Teacher must design more such questions
so as to ensure the achievement of identified CO.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
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
Practical No: 06
Write a simple PHP program to demonstrate use of simple function and parameterized function.
I Practical Significance:
The real power of PHP comes from its functions. PHP has more than built-in functions, and in addition
you can create your own custom functions. PHP has over 1000 built-in functions that can be called
directly, from within a script, to perform a specific task.
Write a simple PHP program to demonstrate use of simple function and parameterized function.
.
PHP functions are similar to other programming languages. A function is a piece of code which
takes one more input in the form of parameter and does some processing and returns a value.
They are built-in functions but PHP gives you option to create your own functions as well. A
function will be executed by a call to the function. You may call a function from anywhere
within a page.
Syntax:
function function_name()
{
//body of function.
}
Function Types
1. Simple function
2. Function with parameter
3. Anonymous function.
Example of Simple function:
<html>
<body>
<?php
function writeMessage()
writeMessage();
?>
</body>
</html>
<?php
function addfunc($num1,$num2)
$num=$num1+$num2;
addfunc(50,20);
?>
Anonymous function
Example:
<?php
$a=function() {
};
$a();
?>
Nill
X. Program Code: Teacher must assign a separate program statement to group of 3-4 students.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Note: Below given are few sample questions for reference. Teacher must design more such questions
so as to ensure the achievement of identified CO.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XI. Exercise
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
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
Write a simple PHP program to create PDF document buy using graphics concepts
I Practical Significance:
PHP uses a standard code to display the pdf file in web browser. The process of displaying pdf involves
location of the PDF file on the server and it uses various types of headers to define content composition
in form of type, Disposition, Transfer-Encoding etc
Basic Knowledge: Apply knowledge of basic mathematics, sciences and basic
engineering to solve the computer group related problem.
Discipline Knowledge: Apply computer programming knowledge to slove the computer
group related problems.
Experiments and practices: Plan to perform experiments and practices to use the result
to solve the computer group related problems.
Engineering tools: Apply relevant Computer programming technologies and tools with
an understanding of the limitations.
Individual and Teamwork: Function effectively as a leader and the team member in
diverse/multidisciplinary teams.
Communication: Communicate effectively in oral and written form.
III Competency and Practical skills:
Write a simple PHP program to create PDF document buy using graphics concepts
PHP uses a standard code to display the pdf file in web browser. The process of displaying pdf
involves location of the PDF file on the server and it uses various types of headers to define
content composition in form of type, Disposition, Transfer-Encoding etc. PHP passes the PDF
files to read it on the browser. Browser either shows it or download it from local host server
then display pdf.
Note: PHP is not actually reading the PDF file. It does not recognize File as pdf. It only passes
the PDF file to the browser to be read there. If copy the pdf file inside htdocs folder of XAMPP
then it does not need to specify the file path.
FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without
using the PDFlib library. F from FPDF stands for Free: you may use it for any kind of usage
and modify it to suit your needs.
FPDF has other advantages: high level functions. Here is a list of its main features:
1. Choice of measure unit, page format and margins
2. Page header and footer management
3. Automatic page break
4. Automatic line break and text justification
5. Image support (JPEG, PNG and GIF)
6. Colors
7. Links
8. TrueType, Type1 and encoding support
9. Page compression
Example:
<?php
require('fpdf.php');
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>
Note: Before executing program download fpdf.php and put into current working directory.
X. Program Code: Teacher must assign a separate program statement to group of 3-4 students.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Note: Below given are few sample questions for reference. Teacher must design more such questions
so as to ensure the achievement of identified CO.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
https://www.w3schools.com/php/default.asp
https://www.guru99.com/what-is-php-program.html
https://www.tutorialspoint.com/php/
https://tutorialehtml.com/en/php-tutorial-introduction/
www.tizag.com/phpT/
https://books.goalkicker.com/PHPBook/
https://codecourse.com/watch/php-basics
XII. Assessment Scheme
Inheritance is a mechanism in which one class acquire property of another class. In PHP, The child class
will inherit all the public and protected properties and methods from the parent class. In addition, it can
have its own properties and methods. Constructor is special member function whose task to initialize
objects of class.
Write a simple PHP program to demonstrate use of simple function and parameterized function.
Inheritance:
class Parent
Example:
<?php
class Shape
public $length;
public $width;
public function_construct($length,$width)
$this->length=$length;
$this->width=$width;
public $height;
$this->length =$length;
$this->width=$width;
$this->height=$height;
echo “This length is {$this->length}, the width is {$this->width}, and the height is {$this-
>height}”;
$r=new Rect(10,20,30);
$->intro();
?>
Constructor:
Constructors are special member functions for initialize variables on the newly created object
instances from a class.
When creating a new object, it’s useful to setup certain aspects of the object at the same time.
For example, you might want to set some properties to initial values fetch some information
from a database to populate the object, or register the object in some way.
Constructor hava two types
Default and parameterized constructor.
class emp
private $fname;
private $lname;
$this->fname=$fname;
$this->lname=$lname;
$sid=new emp(“Ramesh”,”Patil”);
$sid->showName();
?>
Nill
X. Program Code: Teacher must assign a separate program statement to group of 3-4 students.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Note: Below given are few sample questions for reference. Teacher must design more such questions
so as to ensure the achievement of identified CO.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
……………………………………………………………………………………………………....
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
……………………………………………………………………………………………………....
……………………………………………………………………………………………………....
XI. Exercise
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
8. https://www.w3schools.com/php/default.asp
9. https://www.guru99.com/what-is-php-program.html
10. https://www.tutorialspoint.com/php/
11. https://tutorialehtml.com/en/php-tutorial-introduction/
12. www.tizag.com/phpT/
13. https://books.goalkicker.com/PHPBook/
14. https://codecourse.com/watch/php-basics
XIII. Assessment Scheme
Practical No. 9:
I Practical Significance:
Introspection
Introspection is the ability of a program to examine an object’s characteristics such as object name,
class name, parent class name, method names and so on. With introspection we can write code that operates
on any class or object.
Function Description
get_class() Returns the name of the class an object belongs to.
get_parent_class() Returns the name of the superclass of the given
class_exists()
Returns TRUE if the string argument is the name of a
class, FALSE otherwise.
get_declared_classes()
Returns an array of strings representing names of classes defined in the
current script.
is_subclass_of()
Returns TRUE if the class of its first argument (an object instance) is a
subclass of the second argument (a class name), FALSE otherwise.
Returns an associative array of var/value pairs representing the name of
get_class_vars() variables in the class and their default values. Variables without default
values will not be included.
Returns an associative array of var/value pairs representing the name of
get_object_vars() variables in the instance and their default values. Variables without values
will not be included.
method_exists()
Returns TRUE if the first argument (an instance) has a method named by
the second argument (a string) and FALSE otherwise.
Takes a string representing a method name, an instance that should have
get_class_methods() such a method, and additional arguments. Returns the result of applying
the method (and the arguments) to the instance.
<? php
class Rectangle
{
var $dim1 = 2;
var $dim2 = 10;
function area()
{
return $this->dim1*$this->dim2;
}
function display ()
{
// any code to display info
}
}
$S = new Rectangle(4,2);
print_r($class_properties);
Array
(
[dim1] => 2
[dim2] => 10
)
Array
(
[dim1] => 4
[dim2] => 2
)
Array
(
[0] => Rectangle
[1] => area
[2] => display
)
Rectangle
Serialization
Serialization of data means converting it into a string of bytes in such a way that you
can produce the original data again from the string via a process as unserialization. After you
have the ability to serialize/unserialize, you can store your serialized string anywhere and
recreate a copy of the data again when needed.
PHP offers two functions, serialize() and unserialize(), which take a value of any type (except
type resource) and encode the value into string form and decode again, respectively.
<!DOCTYPE html>
<html>
<body>
<?php
echo " <h4>Serializing the array</h4></br>";
</body>
</html>
Output:
Serializing the array
a:3:{i:0;s:3:"Red";i:1;s:5:"Green";i:2;s:4:"Blue";}
array(3) { [0]=> string(3) "Red" [1]=> string(5) "Green" [2]=> string(4) "Blue" }
Sr.
no. Name of Resources Suggested Broad Specification Quantity Remark
Computer System
1 with board
specifications
2 Software
Any other resource
3
used
Note: Below given are few sample questions for reference. Teacher must design more such
questions so as to ensure the achievement of identified CO.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XI. Exercise
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
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
Practical No: 10
I Practical Significance:
In this practical we will learn how to design a web page using different controls.
Design a web page using a.Text box, b. Radio button, c. Check box, d. Buttons
Relevant Course Outcome(s):
Write a program to design a web page using a.Text box, b. Radio button, c. Check box,
d. Buttons
a) Textbox:
A text input field allows a user to enter a single line of text .
Example: For welcome.html file and it has a text field and submit button.
<html>
<body>
<form action=”welcome.php” method=”get”>
<input type=”text” name=”user”/>
<input type=”submit” value=”Submit” />
</form>
</body>
</html>
b) Radio button:
Radio buttons let a user select only one of a limited number of choices:
Example:
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label><br>
<input type="radio" id="female" name="gender" value="female">
<label for="female">Female</label><br>
<input type="radio" id="other" name="gender" value="other">
<label for="other">Other</label>
c) Check box:
<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
<label for="vehicle1"> I have a bike</label><br>
<input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
<label for="vehicle2"> I have a car</label><br>
<input type="checkbox" id="vehicle3" name="vehicle3" value="Boat">
<label for="vehicle3"> I have a boat</label><br>
d) Buttons :
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
X. Program Code: Teacher must assign a separate program statement to group of 3-4
students.
1. Write a program to design a registration form using textbox, radio button, checkbox and
button.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
Note: Below given are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.
1. Write a use and syntax of following controls:
a. Textbox b. Radio button
c. Check box d. Buttons
(Space for Answer)
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XII. Exercise
1. Develop web page and do validation using control text box, radio button, check box
and button.
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
……………………………………………………………………………………………
………………………………………………………………………………………………
……………………………………………………………………………………………………
…………………………………………………………………………………………………
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
111l
Practical No: 11
Design a web page using following form controls:
a. List box, b. Combo box, c. Hidden field box
V Practical Significance:
In this practical we will learn how to design a web page using different controls.
Design a web page using a.List box, b. Combo box, c. Hidden field box
Relevant Course Outcome(s):
Write a program to design a web page using a.List box, b. Combo box, c. Hidden field box
a) List box:
A text input field allows a user to enter a single line of text.
Example: For welcome.html file and it has a text field and submit button.
<html>
<head>
<title>List Box</title>
</head>
<body>
<form action="" method="post">
<select name="foods[]" size="3">
<option value="Tomatoes">Tomatoes</option>
<option value="Cucumbers">Cucumbers</option>
<option value="Celery">Celery</option>
</select><br>
<input type="submit" name="submit" value="Submit"/>
</form>
<?php
$c= $_POST['foods'];
if(isset($c))
{
echo 'You have chosen ';
foreach($c as $key => $value)
{
echo $value;
}
}
else
{
echo "You haven't selected any foods";
}
?>
</body>
</html>
X. Resources used:
1. Write a program to design a form using list box, combo box and Hidden field box.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
…………………………………………………………………………………………………
………………………………………………………………………………………………
Note: Below given are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.
a. Write a use and syntax of following controls:
b. List box b. Hidden field box
c. Combo box
( Space for Answer)
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XIV. Exercise
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
b. https://www.w3schools.com/php/default.asp
c. https://www.guru99.com/what-is-php-program.html
d. https://www.tutorialspoint.com/php/
e. https://tutorialehtml.com/en/php-tutorial- introduction/
f. www.tizag.com/phpT/
g. https://books.goalkicker.com/PHPBook/
h. https://codecourse.com/watch/php-basics
I Practical Significance:
Form validation is required to prevent web form abuse by malicious users. Improper
validation of form data is one of the main causes of security vulnerabilities. PHP provides
some inbuilt function using these functions that input data can be validated.
PHP provides some inbuilt function, using these functions that input data can be validated.
empty() function will ensure that text field is not blank it is with some data,
function accepts a variable as an argument and returns. It TRUE when the text field have
filled with some data otherwise it return FALSE.
is_numeric() function will ensure that data entered in a text field is a numeric
value, the function accepts a variable as an argument and returns TRUE when the text
field is submitted with numeric value otherwise it return FALSE.
preg_match() function is specifically used to performed validation for entering text
in the text field, function accepts a “regular expression” argument and a variable as an
argument which has to be in specific pattern. Typically it is for validating email, IP
address and Pin code information in a form.
Example:
A php page fromvalidation.php is having three text field name, mobile number and email from
user, on clicking submit button a data will be submitted to PHP script validate.php on the server,
which will perform three different validation on these three text fields, it will check that name
should not be blank, mobile number should be in numeric form and the email is validated with an
email pattern.
Formvalidation.php
<html>
<body>
<form method="post" action="validdata.php">
<center>
<br><br>Enter Name <input type="text" name="sname">
<br><br>Mobile Number <input type="text" name="mobileno" maxlength=10>
<br><br>Email id <input type="text" name="email">
<br><br><input type="submit" name="submit" value="Submit">
</center>
</form>
</body>
</html>
validate.php
<?php
$msg=0;
if($_SERVER['REQUEST_METHOD']=="POST")
{
if(empty($_POST['sname'] ))
{
echo "<br>Name can't be blank";
$msg=1;
}
if(!is_numeric($_POST['mobileno']))
{
echo "<br>Enter valid Mobile Number";
$msg=1;
}
if(!preg_match($pattern,$_POST['email']))
{
echo "<br>Enter valid Email id";
$msg=1;
}
if($msg==0)
{
echo "Data has been recorded successfully";
}
}
?>
X. Program Code: Teacher must assign a separate program statement to group of 3-4
students.
Write a simple PHP program to check that emails are valid.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Enlist and explain different method provided by php for web page validation.
I Practical Significance:
In this practical we will learn how to create cookie, modify it and delete
it.Also we will learn how to start a session, get session variables and
destroy a session.
A cookie is a small file with the maximum size of 4KB that the web server stores
on the client computer. They are typically used to keeping track of information
such as a username that the site can retrieve to personalize the page when the user
visits the website next time.
Syntax:
setcookie(name, value, expire, path, domain, secure);
Only the name parameter is required. All other parameters are optional.
Program for creating cookie
<?php
$cookie_name = "Teacher";
$cookie_value = "Kimaya";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
?>
<html>
<body>
<?php
if (!isset($_COOKIE[$cookie_name]))
{
echo "Cookie named '" . $cookie_name . "' is not set!";
}
Else
{
echo "Cookie '" . $cookie_name . "' is set! <br>";
echo "Value is: " . $_COOKIE[$cookie_name];
}
?>
</body>
</html>
Output:
Cookie ' Teacher ' is set!
Value is: Kimaya
b. Session in PHP
A session is a way to store information (in variables) to be used across multiple pages.
Unlike a cookie, the information is not stored on the users computer.
Session variables are set with the PHP global variable: $_SESSION.
Now, let's create a new page called "demo_session1.php". In this page, we start a new
PHP session and set some session variables:
<?php
// Start the session
session_start();
?>
<!DOCTYPE html>
<html>
<body>
<?php
// Set session variables
$_SESSION["favcolor"] = "green";
$_SESSION["favanimal"] = "cat";
echo "Session variables are set.";
?>
</body>
</html>
Output:
Session variables are set.
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
…………….………………………………………………………………………………
……………………………………………………………………………………………..
X 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.
a. Define cookie.
b. Define session.
c. Write difference between cookie and session .
( Space for Answer)
……………………………………………………………………………………………
…………………………………………………………………………………………….
……………………………………………………………………………………………
……………………………………………………………………………………………
……………………………………………………………………………………………
…………………………………………………………………………………………..
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
……………………………………………………………………………………………...
……………………………………………………………………………………………..
XI Exercise
………………………………………………………………………………
………………………………………………………………………………
………………………………………………………………………………
………………………………………………………………………………………….
……………………………………………………………………………………………
……………………………………………………………………………………………
……………………………………………………………………………………………
………………………………………………………………………………...
…………………………………………………………………………………………….
…………………………………………………………………………………………….
……………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
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
Practical No: 14
Write a PHP program for sending and receiving plain text message (e-mail).
I Practical Significance:
PHP mail:
PHP mail() is an inbuilt PHP function which is used to send emails from PHP scripts.
Syntax:
mail (to,subject,message,headers,parameters)
This mail() function accepts five parameters as follows and (the last two are optional).
Parameters Details
message The actual email body where you can insert main messages.
<html>
<head>
<title> Email using PHP</title>
</head>
<body>
<?php
$to=”xyz@example.com”;
$subject=”Test mail”;
$message=”This is HTML message”;
$header=”From: abc@gmail.com”;
$header .= “Cc:pqr@xyzdomain.com”;
$retvalue=mail($to,$subject,$message,$header);
If($retvalue == true)
{
Echo “ Message sent successfully”;
}
Else
{
Echo “ Message could not be sent”;
}
?>
</body>
</html>
2 Software
3 Any other resource used
X. Program Code: Teacher must assign a separate program statement to group of 3-4
students.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Note: Below given are few sample questions for reference. Teacher must design more such
questions so as to ensure the achievement of identified CO.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XI. Exercise
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
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
Practical No: 15
I Practical Significance:
In PHP using MYSQL data can be enter into database . Also we can retrieve and present data
from database.
II Relevant Program Outcomes (POs)
After a database and a table have been created, we can start adding data in them.
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn)
{
if (mysqli_query($conn,$sql))
{
echo "New record inserted successfully";
} else {
echo "could not insert record: " . mysqli_error ($conn);
}
Mysqli_close ($conn);
?>
The SELECT statement is used to select data from one or more tables:
The following example selects the id, firstname and lastname columns from the MyGuests table and displays it on the
page:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli_connect ($servername, $username, $password, $dbname);
// Check connection
if (!$conn)
{
die ("Connection failed: " . mysqli_connect_error ( ));
}
if (mysqli_num_rows($result) > 0) {
// output data of each row
while ($row = mysqli_fetch_assoc($result))
{
echo "id: " . $row["id"] . " . Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
}
} else
{
echo "0 results";
}
Mysqli_close ($conn);
?>
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
2 Software
3 Any other resource used
X. Program Code: Teacher must assign a separate program statement to group of 3-4
students.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Note: Below given are few sample questions for reference. Teacher must design more such
questions so as to ensure the achievement of identified CO.
1. What is MYSQL? How it is used in PHP?
2. How to create database in MYSQL?
3. Name to functions of PHP to connect MYSQL database.
4. Explain mysqli_connect () function.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XII. Exercise
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
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
Practical No: 16
I Practical Significance:
The update keyword is basically used to modify or edit the existing records in the database table. It
usually need a where clause to find out in which record change is to be done. It is must to specify the
where clause otherwise all records of that table got modify.
Syntax:
UPDATE table_name SET column1=value1,column2=value2... WHERE column = value
<?php
//connect database
$con=mysqli_connect ("localhost","root","","Employee") ;
If(!$con)
{
die(‘error in connection’.mysqli_error());
}
//select the database
mysqli_select_db(“mydb”,$con);
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
VIII. Resources used:
Sr.
no. Name of Resources Suggested Broad Specification Quantity Remark
Computer System with
1 board specifications
2 Software
3 Any other resource used
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Note: Below given are few sample questions for reference. Teacher must design more such
questions so as to ensure the achievement of identified CO.
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XI. Exercise
……………………………………………………………………………………………………..
………………………………………………………………………………………………………
…………………………………………………………………………………………………….
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
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