0% found this document useful (0 votes)
40 views123 pages

WT Unit 5

Uploaded by

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

WT Unit 5

Uploaded by

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

Noida Institute of Engineering and Technology, Greater Noida

Unit V PHP

Unit: 5

Introduction to PHP

Ankur Chaudhary
B.Tech, 3rd year Assistant Professor
Information Technology

Ankur Chaudhary Web Technology UNIT 5 1


12/13/2024
Profile
Dedicated and innovative computer science professional with a strong research
background and a deep passion for technology. I hold a Master's degree in Computer
Science . Over the past 8 years, I have been actively involved in research projects focused
on Wireless sensor network, machine learning, natural language processing, and computer
vision. My expertise lies in web development in the field of computer science. Throughout
my academic journey, I have contributed to several published research papers and have
presented my work at prestigious conferences. Proficient in programming languages like
Python and Java, I possess a problem-solving mindset and a knack for identifying creative
solutions to complex challenges.

Research Publications: 14
Grant Patent: 02
Patent: 06
12/13/2024 Ankur Chaudhary Web Technology UNIT 5 2
Contents
• Evaluation Scheme
• Syllabus
• Branch wise syllabus
• Course Objective
• Course Outcome
• Program Outcome
• CO-PO Mapping
• PSO
• CO- PSO Mapping
• PEO
• Result analysis
• Paper template
• Prerequisites
• Introduction to subject
• Unit objective

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 3


Contents
• Topic objective
– Introduction to PHP,
– Basic Syntax, Variables & Constants
– Data Type, Operator & Expressions
– Control flow and Decision making statements
– Functions, Strings, Arrays
– Understanding file & directory
– Opening and closing, a file, Coping, renaming and deleting a file
– Working with directories, Creating and deleting folder
– File Uploading & Downloading
– Introduction to Session Control
– Session Functionality
– What is a Cookie

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 4


Contents
– Setting Cookies with PHP
– Using Cookies with Sessions
– Deleting Cookies
– Registering Session variables
– Destroying the variables and Session.
• Video Links
• Daily Quiz
• Weekly Assignment
• MCQs
• Expected Questions in University Exams
• Summary
• References

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 5


Evaluation Scheme

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 6


Syllabus
Unit Topic

I Introduction: Introduction to Web Technology, History of Web and Internet,


Connecting to Internet, Introduction to Internet services and tools, Client-
Server Computing, Protocols Governing Web, Basic principles involved in
developing a web site, Planning process, Types of Websites, Web Standards
and W3C recommendations, Web Hosting basics, introduction to web testing,
functional testing, usability and visual testing, Performance and load testing.

II HTML: What is HTML, DOM- Introduction to Document Object Model, Basic


structure of an HTML document, Mark up Tags, Heading-Paragraphs , Line
Breaks, Understand the structure of HTML tables. Lists, Working with
Hyperlinks, Image Handling, Understanding Frames and their needs, HTML
forms for User inputs. New form Elements- date, number, range, email, search
and data list, Understanding audio, video and article tags. XML: Introduction,
Tree, Syntax, Elements, Attributes, Namespaces, Display, HTTP request, Parser,
DOM, XPath, XSLT, XQuerry, XLink, Validator, DTD, Schema, Server

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 7


Syllabus
III Concept of CSS 3: Creating Style Sheet, CSS Properties , CSS
Styling(Background, Text Format, Controlling Fonts) , Working with block
elements and objects , Working with Lists and Tables , CSS Id and Class, Box
Model(Introduction, Border properties, Padding Properties, Margin properties)
CSS Advanced(Grouping, Dimension, Display, Positioning, Floating, Align,
Pseudo class, Navigation Bar, Image Sprites, Attribute sector) , CSS Color,
Creating page Layout and Site. Bootstrap: Introduction, Bootstrap grid system,
Bootstrap Components.
IV JavaScript Essentials: Introduction to Java Script , Javascript Types , Var, Let and
Const Keywords, Operators in JS , Conditions Statements , Java Script Loops, JS
Popup Boxes , JS Events , JS Arrays, Working with Arrays, JS Objects ,JS
Functions , Using Java Script in Real time , Validation of Forms, Arrow functions
and default arguments, Template Strings, Strings methods, Callback functions,
Object de-structuring, Spread and Rest Operator, Typescript fundamentals,
Typescript OOPs- Classes, Interfaces, Constructor etc. Decorator and Spread
Operator, Difference == & ===, Asynchronous Programming in ES6, Promise
Constructor, Promise with Chain, Promise Race.

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 8


Syllabus
V Introduction to PHP, Basic Syntax, Variables & Constants, Data Type,
Operator & Expressions, Control flow and Decision making statements,
Functions, Strings, Arrays Working with files and directories: Understanding
file& directory, Opening and closing, a file, Coping, renaming and deleting a
file, working with directories, Creating and deleting folder, File Uploading &
Downloading. Session & Cookies: Introduction to Session Control, Session
Functionality What is a Cookie, Setting Cookies with PHP. Using Cookies with
Sessions, Deleting Cookies, Registering Session variables, Destroying the
variables and Session.

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 9


Branch wise Applications

• Resource Sharing
• Server-Client model
• Communication Medium
• Access to remote information
• Person-to-person communication
• Electronic commerce
• Cloud-based Applications
• AI and Expert System
• Neural Networks and parallel programming
• Decision support and office automation systems etc.

/13/2024 Ankur Chaudhary Web Technology UNIT 5 10


Course Objective

• This course covers different aspect of web technology such as HTML, CSS, and
issues of web technology, client and server side issue. The general objectives of
this course are to provide fundamental concepts of Internet; Web Technology
and Web Programming. Students will be able to build a proper responsive
website.

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 11


Course Outcome

At the end of the course, the student will be able

Course Outcomes (CO) Bloom’s


Knowledge
Level (KL)
Recalling the basic facts and explaining the basic K1, K2
ideas of Web technology and web hosting.
Applying and creating various HTML5 semantic K3, K6
elements and application with working on HTML
forms for user input.
Understanding and applying the concepts of Creating K2, K3
Style Sheet (CSS)3 and bootstrap.
Analysing and implementing concept of Java Script K4, K6
and its applications.
Creating and evaluating dynamic web pages using the K5, K6
concept of PHP

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 12


Program Outcome

1. Engineering knowledge
2. Problem analysis
3. Design/development of solutions
4. Conduct investigations of complex problems
5. Modern tool usage
6. The engineer and society
7. Environment and sustainability
8. Ethics
9. Individual and team work
10. Communication
11. Project management and finance
12. Life-long learning
Ankur Chaudhary Web Technology
/13/2024 13
UNIT 5
CO-PO Mapping

The highlighted text shows the mapping of course outcome with PO mapping
of this unit

Subject
Code is
Not
Assigne PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
d

3 2 2 1 1 1 1 1 3 3 2 3

3 2 3 1 3 2 2 1 3 3 3 3
3 2 3 2 3 2 2 2 3 3 2 3
3 3 3 2 3 2 2 2 3 3 2 3
3 3 3 2 3 2 2 2 3 3 2 3
Averag 2.4 2.8 1.6 2.6 1.8 1.8 1.6 3 3 2.2 3
e
3
12/13/2024 Ankur Chaudhary Web Technology UNIT 5 14
Program Specific Outcomes

 PSO1: Work as a software developer, database administrator, tester or


networking engineer for providing solutions to the real world and
industrial problems.
 PSO2:Apply core subjects of information technology related to data
structure and algorithm, software engineering, web technology, operating
system, database and networking to solve complex IT problems.
 PSO3: Practice multi-disciplinary and modern computing techniques by
lifelong learning to establish innovative career.
 PSO4: Work in a team or individual to manage projects with ethical
concern to be a successful employee or employer in IT industry.

Ankur Chaudhary Web Technology UNIT 5 15


13/2024
CO-PSO Mapping

The highlighted text shows the mapping of course outcome with PSO mapping
of this unit
Course Program Specific Outcomes
Outcomes
PSO1 PSO2 PSO3 PSO4

3 3 2 3

3 3 3 2

3 3 2 2

3 2 3 2

3 2 2 2

AVG 3 2.6 2.4 2.2


12/13/2024 Ankur Chaudhary Web Technology UNIT 5 16
Program Educational Objectives

• PEO1: able to apply sound knowledge in the field of information


technology to fulfill the needs of IT industry.

• PEO2: able to design innovative and interdisciplinary systems through


latest digital technologies.

• PEO3: able to inculcate professional and social ethics, team work and
leadership for serving the society.

• PEO4: able to inculcate lifelong learning in the field of computing for


successful career in organizations and R&D sectors.

/13/2024 Ankur Chaudhary Web Technology UNIT 5 17


Result Analysis

• Result of 2022-23: 98.7%

• Average Marks: 54.33

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 18


End Semester Question Paper Template

B TECH
(SEM-V) THEORY EXAMINATION 20__-20__
Time: 3 Hours Total Marks:
100
Note: 1. Attempt all Sections. If require any missing data; then choose
suitably.
SECTION A
1. Attempt all questions in brief. 1 x 10 = 10
Q.No. Question Marks CO
1 1
2 1
. .
10 1

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 19


End Semester Question Paper Template

2. Attempt of the following: 5 x 2 = 20


Q.No. Question Marks CO
1 2
2 2
. .
5 2

SECTION B
3. Attempt any five part of the following: 5 x 6 = 30

Q.No. Question Marks CO

1 6
. 6
7 6
12/13/2024 Ankur Chaudhary Web Technology 20
UNIT 5
End Semester Question Paper Template

4. Attempt any one part of the following: 1 x 10 = 10


Q.No. Question Marks CO

1 10
2 10
5. Attempt any one part of the following: 1 x 10 = 10
Q.No. Question Marks CO
1 10
2 10

6. Attempt any one part of the following: 1 x 10 = 10


Q.No. Question Marks CO
1 10
2 10
Ankur Chaudhary Web Technology
12/13/2024 21
UNIT 5
End Semester Question Paper Template

7. Attempt any one part of the following: 1 x 10 = 10


Q.No. Question Marks CO

1 10
2 10
8. Attempt any one part of the following: 1 x 10 = 10
Q.No. Question Marks CO
1 10
2 10

Ankur Chaudhary Web Technology


12/13/2024 22
UNIT 5
Prerequisite

• The student should have knowledge of


– Web
– Browser and application
– Hardware and data sharing
• The basic knowledge of C

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 23


Brief Introduction to Subject

• Web Technology refers to the various tools and techniques that are
utilized in the process of communication between different types of
devices over the internet.
• A web browser is used to access web pages. Web browsers can be defined
as programs that display text, data, pictures, animation, and video on the
Internet.
• Hyperlinked resources on the World Wide Web can be accessed using
software interfaces provided by Web browsers.
• https://www.youtube.com/results?
search_query=Web+Technonogies

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 24


Topic Mapping with Course Outcome
Topics Course outcome
Introduction to PHP, Basic Syntax, Variables &
Constants, Data Type, Operator & Expressions, Control CO5
flow and Decision making statements, Functions,
Strings, Arrays

Working with files and directories: Understanding CO5


file& directory, Opening and closing, a file, Coping,
renaming and deleting a file, working with directories,
Creating and deleting folder, File Uploading &
Downloading.
CO5
Session & Cookies: Introduction to Session Control,
Session Functionality What is a Cookie, Setting Cookies
with PHP. Using Cookies with Sessions, Deleting
Cookies, Registering Session variables, Destroying the
variables and Session.

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 25


Unit Objective

• Read, understand and implement the PHP language in real world projects.

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 26


Topic

Introduction to PHP, syntax, variables, constants

Topic objective

To discuss about basics of PHP with its syntax, variables and constants.

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 27


Introduction to PHP (CO5)
• The term PHP is an acronym for PHP: Hypertext Preprocessor. PHP is a server-
side scripting language designed specifically for web development.
• PHP is a server side scripting language that is embedded in HTML. It is used to
manage
• dynamic content, databases, session tracking, even build entire e-commerce
sites.
• It is integrated with a number of popular databases, including MySQL,
PostgreSQL,
• Oracle, Sybase, Informix, and Microsoft SQL Server.
• PHP is pleasingly zippy in its execution, especially when compiled as an Apache
module on the Unix side. The MySQL server, once started, executes even very
complex queries with huge result sets in record-setting time.
• PHP supports a large number of major protocols such as POP3, IMAP, and LDAP.
PHP4 added support for Java and distributed object architectures (COM and
CORBA), making n-tier development a possibility for the first time.
• PHP is forgiving: PHP language tries to be as forgiving as possible.
• PHP Syntax is C-Like.
12/13/2024 Ankur Chaudhary Web Technology UNIT 5 28
Introduction to PHP (CO5)
• It supports main protocols like HTTP Basic, HTTP Digest, IMAP, FTP, and others.
Common Uses of PHP:
PHP performs system functions, i.e. from files on a system it can create, open,
read, write, and close them. The other uses of PHP are:
• PHP can handle forms, i.e. gather data from files, save data to a file, thru email
you can send data, return data to the user.
• You add, delete, modify elements within your database thru PHP.
• Access cookies variables and set cookies.
• Using PHP, you can restrict users to access some pages of your website.
• It can encrypt data.

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 29


Basics syntax (CO5)
• A PHP script can be placed anywhere in the document.
• A PHP script starts with <?php and ends with ?>:
<?php
// PHP code goes here
?>
• The default file extension for PHP files is ".php". A PHP file normally contains
HTML tags, and some PHP scripting code.
• Below, we have an example of a simple PHP file, with a PHP script that uses a
built-in PHP function "echo" to output the text "Hello World!" on a web page:
• Example-<html>
<head><title>Hello World</title>
<body><?php echo "Hello, World!";?></body></html

12/13/2024 Ankur Chaudhary Web Technology 30


UNIT 5
Basics syntax (CO5)
Web Server - PHP will work with virtually all Web Server software, including
Microsoft's Internet Information Server (IIS) but then most often used is freely
available Apache Server.
Download Apache for free here: http://httpd.apache.org/download.cgi
Database - PHP will work with virtually all database software, including Oracle
and Sybase but most commonly used is freely available MySQL database.
Download MySQL for free here:
http://www.mysql.com/downloads/index.html
PHP Parser - In order to process PHP script instructions, a parser must be
installed to generate HTML output that can be sent to the Web Browser. This
tutorial will guide you how to install PHP parser on your computer.

12/13/2024 Ankur Chaudhary Web Technology 31


UNIT 5
Variables & Constants (CO5)
• In PHP, variables and constants are used to store and represent data in a
program. However, they have some key differences:
Variables:
• Variables are used to store data that may change during the execution of a
script.
• The value of a variable can be reassigned multiple times during the program's
execution.
• PHP variables start with a dollar sign ($) followed by the variable name (e.g.,
$variableName).
• Variables are case-sensitive, so $variable and $Variable are considered different
variables.
• You don't need to declare variables explicitly before using them; they are
created dynamically when assigned a value.

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 32


Variables & Constants (CO5)

• $name = "John"; // String variable


• $age = 30; // Integer variable
• $height = 1.75; // Float variable
• $isStudent = true; // Boolean variable
Rules for declaring PHP variable:
• A variable must start with a dollar ($) sign, followed by the variable name.
• It can only contain alpha-numeric character and underscore (A-z, 0-9, _).
• A variable name must start with a letter or underscore (_) character.
• A PHP variable name cannot contain spaces.
• One thing to be kept in mind that the variable name cannot start with a number
or special symbols.
• PHP variables are case-sensitive, so $name and $NAME both are treated as
different variable.

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 33


Variables & Constants (CO5)
PHP Variable: Declaring string, integer, and float
Let's see the example to store string, integer, and float values in PHP variables.
<?php
$str="hello string";
$x=200;
$y=44.6;
echo "string is: $str <br/>";
echo "integer is: $x <br/>";
echo "float is: $y <br/>";
?>

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 34


Variables & Constants (CO5)
Output:
string is: hello string
integer is: 200
float is: 44.6

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 35


Variables & Constants (CO5)
PHP constants are name or identifier that can't be changed during the execution
of the script except for magic constants, which are not really constants.
PHP constants can be defined by 2 ways:
• Using define() function
• Using const keyword
Constants are similar to the variable except once they defined, they can never be
undefined or changed.

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 36


Variables & Constants (CO5)
They remain constant across the entire program. PHP constants follow the same PHP
variable rules.
For example, it can be started with a letter or underscore only. Conventionally, PHP
constants should be defined in uppercase letters.
1. PHP constant: define()
Use the define() function to create a constant.
It defines constant at run time. Let's see the syntax of define() function in PHP.
define(name, value, case-insensitive)
<?php
define("MESSAGE","Hello PHP");
echo MESSAGE;
?>
Output:
Hello PHP

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 37


Variables & Constants (CO5)

2. PHP constant: const keyword


PHP introduced a keyword const to create a constant. The const keyword defines
constants at compile time. It is a language construct, not a function. The constant
defined using const keyword are case-sensitive.
<?php
const MESSAGE="Hello const by PHP";
echo MESSAGE;
?>
Output:
Hello const by PHP

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 38


Daily Quiz

1) PHP stands for -


A)Hypertext Preprocessor
B)Pretext Hypertext Preprocessor
C)Personal Home Processor
D)None of the above

2) Who is known as the father of PHP?


A)Drek Kolkevi
B)List Barely
C)Rasmus Lerdrof
D)None of the above

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 39


Daily Quiz

3) Which of the following statements is true about variables and constants in


PHP?
A) Variables are used for storing data that remains the same throughout the script
execution.
B) Constants can be reassigned multiple times during the execution of a script.
C) Variables are case-insensitive, while constants are case-sensitive.
D) Constants are created dynamically when assigned a value, while variables need
to be declared before use.
4)Variable name in PHP starts with -
A)! (Exclamation)
B)$ (Dollar)
C)& (Ampersand)
D)# (Hash)

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 40


Daily Quiz

5) Which of the following is the default file extension of PHP?


A).php
B).hphp
C).xml
D).html

6) Which of the following is not a variable scope in PHP?


A)Extern
B)Local
C)Static
D)Global

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 41


Topic

Overview of Data Type, Operator & Expressions in PHP

Topic objective

To discuss about data type, operator and expression in PHP

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 42


Recap

In the last lecture we have discussed about

- Introduction of basic of PHP with its syntax variables and constant.

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 43


Data type (CO5)

PHP data types are used to hold different types of data or values. PHP supports 8
primitive data types that can be categorized further in 3 types:
• Scalar Types (predefined)
• Compound Types (user-defined)
• Special Types

1 Scalar Types- It holds only single value. There are 4 scalar data types in PHP.
• boolean
• integer
• float
• string

Ankur Chaudhary Web Technology


12/13/2024 44
UNIT 5
Data type (CO5)

2 Compound Types- It can hold multiple values. There are 2 compound data types
in PHP.
• array
• object

3 Special Types- There are 2 special data types in PHP.


• resource
• NULL

Ankur Chaudhary Web Technology


12/13/2024 45
UNIT 5
Operator (CO5)

PHP Operator is a symbol i.e used to perform operations on operands. In


simple words, operators are used to perform operations on variables or
values.

Ankur Chaudhary Web Technology


12/13/2024 46
UNIT 5
Operator (CO5)

Ankur Chaudhary Web Technology


12/13/2024 47
UNIT 5
Expression (CO5)

• An expression is a bit of PHP that can be evaluated to produce a value.


The simplest expressions are literal values and variables.
• A literal value evaluates to itself, while a variable evaluates to the value
stored in the variable.
• More complex expressions can be formed using simple expressions and
operators.

Ankur Chaudhary Web Technology


12/13/2024 48
UNIT 5
Control flow and Decision making statements (CO5)

1 PHP if- statement allows conditional execution of code. It is executed if condition


is true. If statement is used to executes the block of code exist inside the if
statement only if the specified condition is true.
• Syntax
– if(condition){
– //code to be executed
– }

Ankur Chaudhary Web Technology


12/13/2024 49
UNIT 5
Control flow and Decision making statements (CO5)

2 PHP if-else statement is executed whether condition is true or false. If-else


statement is slightly different from if statement. It executes one block of code if the
specified condition is true and another block of code if the condition is false.
• Syntax
– if(condition){
– //code to be executed if true
– }else{
– //code to be executed if false
– }

Ankur Chaudhary Web Technology


12/13/2024 50
UNIT 5
Control flow and Decision making statements (CO5)

3 The PHP if-else-if is a special statement used to combine multiple if-else


statements. So, we can check multiple conditions using this statement.
• Syntax
– if (condition1){
– //code to be executed if condition1 is true
– } elseif (condition2){
– //code to be executed if condition2 is true
– } elseif (condition3){
– //code to be executed if condition3 is true
– ....
– } else{
– //code to be executed if all given conditions are false
– }

Ankur Chaudhary Web Technology


12/13/2024 51
UNIT 5
Control flow and Decision making statements (CO5)

4 PHP switch statement is used to execute one statement from multiple conditions.
It works like PHP if-else-if statement.
• Syntax
– switch(expression){
– case value1:
– //code to be executed
– break;
– case value2:
– //code to be executed
– break;
– ......
– default:
– code to be executed if all cases are not matched;
– }

Ankur Chaudhary Web Technology


12/13/2024 52
UNIT 5
Control flow and Decision making statements (CO5)

5 PHP for loop can be used to traverse set of code for the specified number of
times. It should be used if the number of iterations is known otherwise use while
loop. This means for loop is used when you already know how many times you want
to execute a block of code. It allows users to put all the loop related statements in
one place.
• Syntax
– for(initialization; condition; increment/decrement){
– //code to be executed
– }

Ankur Chaudhary Web Technology


12/13/2024 53
UNIT 5
Control flow and Decision making statements (CO5)

6 PHP while loop can be used to traverse set of code like for loop. The while loop
executes a block of code repeatedly until the condition is FALSE. Once the condition
gets FALSE, it exits from the body of loop. It should be used if the number of
iterations is not known.
• Syntax
– while(condition){
– //code to be executed
– }

Ankur Chaudhary Web Technology


12/13/2024 54
UNIT 5
Control flow and Decision making statements (CO5)

7 PHP do-while loop can be used to traverse set of code like php while loop. The
PHP do-while loop is guaranteed to run at least once. The PHP do-while loop is used
to execute a set of code of the program several times. If you have to execute the
loop at least once and the number of iterations is not even fixed, it is recommended
to use the do-while loop.
• Syntax
– do{
– //code to be executed
– }while(condition);

Ankur Chaudhary Web Technology


12/13/2024 55
UNIT 5
Control flow and Decision making statements (CO5)

8 PHP break statement breaks the execution of the current for, while, do-while,
switch, and for-each loop. If you use break inside inner loop, it breaks the execution
of inner loop only. The break statement can be used in all types of loops such as
while, do-while, for, foreach loop, and also with switch case.
• Syntax
– jump statement;
– break;

Ankur Chaudhary Web Technology


12/13/2024 56
UNIT 5
Daily Quiz

1) Variable name in PHP starts with -


! (Exclamation)
$ (Dollar)
& (Ampersand)
# (Hash)

2) Default file extension of PHP?


A).php
B).hphp
C).xml
D).html

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 57


Daily Quiz

3) Which of the following is used to display the output in PHP?


A)echo
B)write
C)print
D)Both (a) and (c)
4) Which of the following is correct to add a comment in php?
A)& …… &
B)// ……
C)/* …… */
D)Both (b) and (c)

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 58


Topic

Overview of function, string & arrays in PHP

Topic objective

To discuss about function, string and arrays in PHP

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 59


Recap

In the last lecture we have discussed about

- Introduction of basic of PHP with Data Type, Operator & Expressions,


Control flow and Decision making statements.

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 60


Functions (CO5)

• PHP function is a piece of code that can be reused many times. It can take input
as argument list and return value. There are thousands of built-in functions in
PHP.
• In PHP, we can define Conditional function, Function within
Function and Recursive function also.
• PHP User-defined Functions
• We can declare and call user-defined functions easily. Let's see the syntax to
declare user-defined functions.
• Syntax
– function functionname(){
– //code to be executed
– }

Ankur Chaudhary Web Technology


12/13/2024 61
UNIT 5
Functions (CO5)

1 PHP Parameterized functions are the functions with parameters. You can pass any
number of parameters inside a function. These passed parameters act as variables
inside your function. They are specified inside the parentheses, after the function
name. The output depends upon the dynamic values passed as the parameters into
the function.

Ankur Chaudhary Web Technology


12/13/2024 62
UNIT 5
Functions (CO5)
2 PHP call by value function allows you to call function by value and reference both.
In case of PHP call by value, actual value is not modified if it is modified inside the
function.
– <?php
– function adder($str2)
– {
– $str2 .= 'Call By Value';
– }
– $str = 'Hello ';
– adder($str);
– echo $str;
– ?>

Ankur Chaudhary Web Technology


12/13/2024 63
UNIT 5
Functions (CO5)
3 In case of PHP call by reference, actual value is modified if it is modified inside the
function. In such case, you need to use & (ampersand) symbol with formal
arguments. The & represents reference of the variable.
– <?php
– function adder(&$str2)
– {
– $str2 .= 'Call By Reference';
– }
– $str = 'This is ';
– adder($str);
– echo $str;
– ?>

Ankur Chaudhary Web Technology


12/13/2024 64
UNIT 5
Functions (CO5)
4 PHP Default Argument Values Function allows you to define C++ style default
argument values. In such case, if you don't pass any value to the function, it will use
default argument value.
– <?php
– function sayHello($name="Ram"){
– echo "Hello $name<br/>";
– }
– sayHello("Sonoo");
– sayHello();//passing no value
– sayHello("Vimal");
– ?>

Ankur Chaudhary Web Technology


12/13/2024 65
UNIT 5
String (CO5)
PHP string is a sequence of characters i.e., used to store and manipulate text. PHP
supports only 256-character set and so that it does not offer native Unicode
support. There are 4 ways to specify a string literal in PHP.

1 Single Quoted- We can create a string in PHP by enclosing the text in a single-
quote. It is the easiest way to specify string in PHP.
For specifying a literal single quote, escape it with a backslash (\) and to specify a
literal backslash (\) use double backslash (\\).
All the other instances with backslash such as \r or \n, will be output same as they
specified instead of having any special meaning.

Ankur Chaudhary Web Technology


12/13/2024 66
UNIT 5
String (CO5)
2 Doubled Quoted- In PHP, we can specify string through enclosing text within
double quote also.
But escape sequences and variables will be interpreted using double quote PHP
strings.
<?php
$str="Hello text within double quote";
echo $str;
?>
Output:
Hello text within double quote

Ankur Chaudhary Web Technology


12/13/2024 67
UNIT 5
String (CO5)
3 Heredoc syntax (<<<) is the third way to delimit strings. In Heredoc syntax, an
identifier is provided after this heredoc <<< operator, and immediately a new line is
started to write any text. To close the quotation, the string follows itself and then
again that same identifier is provided. That closing identifier must begin from the
new line without any whitespace or tab.
<?php
$str = <<<Demo
It is a valid example
Demo; //Valid code as whitespace or tab is not valid before closing identifier
echo $str;
?>
Output:
It is a valid example

Ankur Chaudhary Web Technology


12/13/2024 68
UNIT 5
String (CO5)
4 Newdoc is similar to the heredoc, but in newdoc parsing is not done.
• It is also identified with three less than symbols <<< followed by an identifier.
• But here identifier is enclosed in single-quote, e.g. <<<'EXP'. Newdoc follows the
same rule as heredocs.
• The difference between newdoc and heredoc is that - Newdoc is a single-quoted
string whereas heredoc is a double-quoted string.

Ankur Chaudhary Web Technology


12/13/2024 69
UNIT 5
Array (CO5)

PHP array is an ordered map (contains value on the basis of key). It is used to hold
multiple values of similar type in a single variable. We don't need to define multiple
variables. By the help of single loop, we can traverse all the elements of an array. We
can sort the elements of array. There are 3 types of array in PHP.
1 PHP indexed array is represented by number which starts from 0. We can store
number, string and object in the PHP array.
All PHP array elements are assigned to an index number by default. There are two
ways to define indexed array:

Ankur Chaudhary Web Technology


12/13/2024 70
UNIT 5
Array (CO5)

• 1st way:
• $season=array("summer","winter","spring","autumn");
• 2nd way:
• $season[0]="summer";
• $season[1]="winter";
• $season[2]="spring";
• $season[3]="autumn";

Ankur Chaudhary Web Technology


12/13/2024 71
UNIT 5
Array (CO5)

2 PHP associative array allows you to associate name/label with each array
elements in PHP using => symbol. Such way, you can easily remember the element
because each element is represented by label than an incremented number. There
are two ways to define associative array:
– 1st way:
– $salary=array("Sonoo"=>"550000","Vimal"=>"250000","Ratan"=>"200000");

– 2nd way:
– $salary["Sonoo"]="550000";
– $salary["Vimal"]="250000";
– $salary["Ratan"]="200000";

Ankur Chaudhary Web Technology


12/13/2024 72
UNIT 5
Array (CO5)

3 PHP multidimensional array is also known as array of arrays. It allows you to store
tabular data in an array. PHP multidimensional array can be represented in the form
of matrix which is represented by row * column.
– $emp = array
– (
– array(1,"sonoo",400000),
– array(2,"john",500000),
– array(3,"rahul",300000)
– );

Ankur Chaudhary Web Technology


12/13/2024 73
UNIT 5
Daily Quiz

1) How to define a function in PHP?


a) functionName(parameters) {function body}
b) function {function body}
c) function functionName(parameters) {function body}
d) data type functionName(parameters) {function body}

2) Which is the right way of declaring a variable in PHP?


a) $3hello
b) $_hello
c) $this
d) $5_Hello

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 74


Topic

Overview of files and directories

Topic objective
To discuss about Understanding file& directory, Opening and closing, a file,
Coping, renaming and deleting a file, working with directories, Creating and
deleting folder, File Uploading & Downloading in PHP

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 75


Understanding file & directory, working with directories
(CO5)
• Now that we have spent some time looking at how to work with files in PHP it is
now time to look at how to work with file system directories.
• PHP provides a number of functions that can be used to perform tasks such as
identifying and changing the current directory, creating new directories, deleting
existing directories and listing the contents of a directory.
1 Creating Directories in PHP- A new directory can be created in PHP using the
mkdir() function. This function takes a path to the directory to be created.
• To create a directory in the same directory as your PHP script simply provide the
directory name. To create a new directory in a different directory specify the full
path when calling mkdir().
• A second, optional argument allows the specification of permissions on the
directory (controlling such issues as whether the directory is writable):
<?php
$result = mkdir ("/path/to/directory", "0777");
?>

Ankur Chaudhary Web Technology


12/13/2024 76
UNIT 5
Understanding file & directory, working with directories
(CO5)
2 Deleting a directory- Directories are deleted in PHP using
the rmdir() function. rmdir() takes a single argument, the name of the directory to be
deleted.
• The deletion will only be successful if the directory is empty. If the directory
contains files or other sub-directories the deletion cannot be performed until
those files and sub-directories are also deleted.
3 To Close a directory- We use closedir() function in order to close a directory after
reading its contents.
Syntax:
$dir_handle = opendir($dir_path);
...
...
closedir($dir_handle);

Ankur Chaudhary Web Technology


12/13/2024 77
UNIT 5
Understanding file & directory, working with directories
(CO5)
4 To open a directory- The opendir() function in PHP is an inbuilt function which is
used to open a directory handle. The path of the directory to be opened is sent as a
parameter to the opendir() function and it returns a directory handle resource on
success, or FALSE on failure. The opendir() function is used to open up a directory
handle to be used in subsequent with other directory functions such as closedir(),
readdir(), and rewinddir().
Syntax:
opendir($path, $context)

Ankur Chaudhary Web Technology


12/13/2024 78
UNIT 5
Understanding file & directory, working with directories
(CO5)
5 To copy a directory- The copy() function is used to make a copy of a specified file. It
makes a copy of the source file to the destination file and if the destination file
already exists, it gets overwritten. The copy() function returns true on success and
false on failure.
Syntax:
Bool copy($source, $dest)

6 To rename a directory- The rename() function in PHP is an inbuilt function which is


used to rename a file or directory. It makes an attempt to change an old name of a
file or directory with a new name specified by the user and it may move between
directories if necessary.

Ankur Chaudhary Web Technology


12/13/2024 79
UNIT 5
Understanding file & directory, working with directories
(CO5)
If the new name specified by the user already exists, the rename() function
overwrites it. The old name of the file and the new name specified by the user are
sent as parameters to the rename() function and it returns True on success and a
False on failure.
Syntax:
rename(oldname, newname, context)

Ankur Chaudhary Web Technology


12/13/2024 80
UNIT 5
Creating and deleting folder (CO5)
• Earlier we have seen about deleting just files which are present in a directory.
Now, What if you have sub directories with files inside the folder.
• In that case the above script won’t able to work. You’ll need to create recursive
function to delete all files, sub-directories and parent directory altogether.
• Simply deleting a folder with using php’s function rmdir() won’t work. It will throw
some exceptions if you attempt to remove folder directly with files in it.
• So first of all you have to delete files one by one from each sub folder and then
delete folders by removing parent folder.

Ankur Chaudhary Web Technology


12/13/2024 81
UNIT 5
Creating and deleting folder (CO5)
<?php
// delete all files and sub-folders from a folder
function deleteAll($dir) {
foreach(glob($dir . '/*') as $file) {
if(is_dir($file))
deleteAll($file);
else
unlink($file);
}
rmdir($dir);
}
?>

Ankur Chaudhary Web Technology


12/13/2024 82
UNIT 5
File Uploading & Downloading (CO5)
Uploading- With PHP, it is easy to upload files to the server. However, with ease
comes danger, so always be careful when allowing file uploads and follow these
steps.

1. Configure The "php.ini" File


2. Create The HTML Form
3. Create The Upload File PHP Script
4. Check if File Already Exists
5. Limit File Size
6. Limit File Type
7. Complete Upload File PHP Script

Ankur Chaudhary Web Technology


12/13/2024 83
UNIT 5
File Uploading & Downloading (CO5)
PHP Download File- PHP enables you to download file easily using built-in readfile()
function. The readfile() function reads a file and writes it to the output buffer.
Syntax

int readfile ( string $filename [, bool $use_include_path = false [, resource


$context ]] )

$filename: represents the file name


$use_include_path: it is the optional parameter. It is by default false. You can set it to
true to the search the file in the included_path.
$context: represents the context stream resource.
int: it returns the number of bytes read from the file.

Ankur Chaudhary Web Technology


12/13/2024 84
UNIT 5
Introduction to Session Control (CO5)
When you work with an application, you open it, do some changes, and then you
close it. This is much like a Session. The computer knows who you are. It knows when
you start the application and when you end. But on the internet there is one
problem: the web server does not know who you are or what you do, because the
HTTP address doesn't maintain state.

Session variables solve this problem by storing user information to be used across
multiple pages (e.g. username, favorite color, etc). By default, session variables last
until the user closes the browser.

So; Session variables hold information about one single user, and are available to all
pages in one application.

Ankur Chaudhary Web Technology


12/13/2024 85
UNIT 5
Introduction to Session Control (CO5)
A session is started with the session_start() function. 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:

Example
<?php
// Start the session
session_start();
?>
<!DOCTYPE html>
<html>
<body>

Ankur Chaudhary Web Technology


12/13/2024 86
UNIT 5
Introduction to Session Control (CO5)
<?php
// Set session variables
$_SESSION["favcolor"] = "green";
$_SESSION["favanimal"] = "cat";
echo "Session variables are set.";
?>
</body>
</html>

Ankur Chaudhary Web Technology


12/13/2024 87
UNIT 5
Session Functions and Functionality (CO5)
• session_abort — Discard session array changes and finish session
• session_cache_expire — Get and/or set current cache expire
• session_cache_limiter — Get and/or set the current cache limiter
• session_commit — Alias of session_write_close
• session_create_id — Create new session id
• session_decode — Decodes session data from a session encoded string
• session_destroy — Destroys all data registered to a session
• session_encode — Encodes the current session data as a session encoded string
• session_gc — Perform session data garbage collection
• session_get_cookie_params — Get the session cookie parameters
• session_id — Get and/or set the current session id
• session_module_name — Get and/or set the current session module
• session_name — Get and/or set the current session name

Ankur Chaudhary Web Technology


12/13/2024 88
UNIT 5
Session Functions and Functionality (CO5)
• session_name — Get and/or set the current session name
• session_regenerate_id — Update the current session id with a newly generated
one
• session_register_shutdown — Session shutdown function
• session_reset — Re-initialize session array with original values
• session_save_path — Get and/or set the current session save path
• session_set_cookie_params — Set the session cookie parameters
• session_set_save_handler — Sets user-level session storage functions
• session_start — Start new or resume existing session
• session_status — Returns the current session status
• session_unset — Free all session variables
• session_write_close — Write session data and end session

Ankur Chaudhary Web Technology


12/13/2024 89
UNIT 5
Cookie (CO5)
A cookie is often used to identify a user. A cookie is a small file that the server
embeds on the user's computer. Each time the same computer requests a page with
a browser, it will send the cookie too. With PHP, you can both create and retrieve
cookie values.

Create Cookies With PHP


A cookie is created with the setcookie() function.

Syntax
setcookie(name, value, expire, path, domain, secure, httponly);

Ankur Chaudhary Web Technology


12/13/2024 90
UNIT 5
Setting Cookie with PHP (CO5)
Setting Cookie In PHP: To set a cookie in PHP, the setcookie() function is used. The
setcookie() function needs to be called prior to any output generated by the script
otherwise the cookie will not be set.

Syntax:

setcookie(name, value, expire, path, domain, security);


Parameters: The setcookie() function requires six arguments in general which are:

Name: It is used to set the name of the cookie.


Value: It is used to set the value of the cookie.

Ankur Chaudhary Web Technology


12/13/2024 91
UNIT 5
Setting Cookie with PHP (CO5)
Expire: It is used to set the expiry timestamp of the cookie after which the cookie
can’t be accessed.
Path: It is used to specify the path on the server for which the cookie will be
available.
Domain: It is used to specify the domain for which the cookie is available.
Security: It is used to indicate that the cookie should be sent only if a secure HTTPS
connection exists.

Ankur Chaudhary Web Technology


12/13/2024 92
UNIT 5
Setting Cookie with PHP (CO5)
PHP sessions can use cookies depending on how you configure them. Have a look at
these settings:

• session.use_cookies (boolean): specifies whether the module will use cookies to


store the session id on the client side. Defaults to 1 (enabled).
• session.use_only_cookies (boolean): specifies whether the module will only use
cookies to store the session id on the client side. Enabling this setting prevents
attacks involved passing session ids in URLs. This setting was added in PHP 4.3.0.
Defaults to 1 (enabled) since PHP 5.3.0.
If you disable session cookies, a GET parameter is used instead.

Ankur Chaudhary Web Technology


12/13/2024 93
UNIT 5
Deleting Cookies (CO5)
PHP sessions can use cookies depending on how you configure them. Have a look at
these settings:

• session.use_cookies (boolean): specifies whether the module will use cookies to


store the session id on the client side. Defaults to 1 (enabled).
• session.use_only_cookies (boolean): specifies whether the module will only use
cookies to store the session id on the client side. Enabling this setting prevents
attacks involved passing session ids in URLs. This setting was added in PHP 4.3.0.
Defaults to 1 (enabled) since PHP 5.3.0.
If you disable session cookies, a GET parameter is used instead.

Ankur Chaudhary Web Technology


12/13/2024 94
UNIT 5
Deleting Cookies (CO5)
Use the setcookie() method to delete the cookies. For that, we need to keep the
expiry date of the past. We can use the isset() function to check if the cookie has
been set before deleting the cookie.

For example, use the $_COOKI[$cookie_name] variable in the isset() function to


check if the above created cookie exist.
In the if block, use the setcookie() function. Inside the function, set $cookie_name as
the first parameter.

if(isset($_COOKIE[$cookie_name])) {
setcookie($cookie_name, "", time()-3600);
}

Ankur Chaudhary Web Technology


12/13/2024 95
UNIT 5
Deleting Cookies (CO5)
We wrote an empty string and time()-3600 for the expiry time for the second
parameter.

As the time() function returns the current time in seconds since Epoch, 3600
subtracted from it will return the past time. Finally, the cookie with the
$cookie_name is deleted. We can also use $cookie_name and null value in the
setcookie() function to delete the cookies.
if(isset($_COOKIE[$cookie_name])) {
setcookie($cookie_name, null);
}
Thus, we can use the setcookie() function to delete cookies in PHP.

Ankur Chaudhary Web Technology


12/13/2024 96
UNIT 5
Registering Session variables (CO5)
• The PHP session is required so that you can store the user information and use it
on different pages of the browser.
• It creates a session with the name or any other useful information you want to
store and access on different pages.
• Even after your page is closed you can access the information until the browser
does not close.
• This is an important thing to understand if a browser is closed then the session is
automatically destroyed.

Ankur Chaudhary Web Technology


12/13/2024 97
UNIT 5
Registering Session variables (CO5)
• We can create the session by writing session_start() and destroy the session by
using session_destroy(). You can access the session variable by
writing $_session[“name”].
<?php
// Starting session
session_start();
// Use of session_register() is deprecated
$username = "PhpScots";
session_register("username");
// Use of $_SESSION is preferred
$_SESSION["username"] = "PhpScots";
?>

Ankur Chaudhary Web Technology


12/13/2024 98
UNIT 5
Destroying the variables and Session (CO5)
Destroying the Variable- The unset() function in PHP resets any variable. If unset() is
called inside a user-defined function, it unsets the local variables.
If a user wants to unset the global variable inside the function, then he/she has to
use $GLOBALS array to do so. The unset() function has no return value.

Ankur Chaudhary Web Technology


12/13/2024 99
UNIT 5
Destroying the variables and Session (CO5)
Destroying the Session- A PHP session can be destroyed by session_destroy()
function. This function does not need any argument and a single call can destroy all
the session variables. If you want to destroy a single session variable then you can
use unset() function to unset a session variable. Here is the example to unset a single
variable −
– <?php
– unset($_SESSION['counter']);
– ?>
– Here is the call which will destroy all the session variables −

– <?php
– session_destroy();
– ?>

Ankur Chaudhary Web Technology


12/13/2024 100
UNIT 5
Daily Quiz

1) Which of the following is used to display the output in PHP?


A)echo
B)write
C)print
D)Both (a) and (c)

2) Which of the following is the use of strlen() function in PHP?


A)The strlen() function returns the type of string
B)The strlen() function returns the length of string
C)The strlen() function returns the value of string
D)The strlen() function returns both value and type of string

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 101


MCQ

3)Which of the following is used for concatenation in PHP?


A)+ (plus)
B)* (Asterisk)
C). (dot)
D)append()

4)Which of the following starts with __ (double underscore) in PHP?


A)Inbuilt constants
B)User-defined constants
C)Magic constants
D)Default constants

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 102


MCQ

5)Which of the following is the use of strpos() function in PHP?


A)The strpos() function is used to search for the spaces in a string
B)The strpos() function is used to search for a number in a string
C)The strpos() function is used to search for a character/text in a string
D)The strpos() function is used to search for a capitalize character in a string

6)How many ways can a session data be stored?


A)3
B)4
C)5
D)6

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 103


MCQ

7)What does PEAR stands for?


A)PHP extension and application repository
B)PHP enhancement and application reduce
C)PHP event and application repository
D)None of the above

8)Which of the following is the correct way to create a function in PHP?


A)Create myFunction()
B)New_function myFunction()
C)function myFunction()
D)None of the above

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 104


MCQ

9)Which of the following PHP function is used to generate unique id?


A)id()
B)mdid()
C)uniqueid()
D)None of the above

10)Which of the following is the correct way of defining a variable in PHP?


A)$variable name = value;
B)$variable_name = value;
C)$variable_name = value
D)variable name as value;

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 105


MCQ

11)Which of the following is the correct use of the strcmp() function in PHP?
A)The strcmp() function is used to compare the strings excluding case
B)The strcmp() function is used to compare the uppercase strings
C)The strcmp() function is used to compare the lowercase strings
D)The strcmp() function is used to compare the strings including case

12)What is the use of fopen() function in PHP?


A)The fopen() function is used to open folders in PHP
B)The fopen() function is used to open remote server
C)The fopen() function is used to open files in PHP
D) None of the above

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 106


Glossary

• The filesize() function returns the file size in ___________


• _______function is used to determine a file’s last access time.
• _______function is useful when you want to output the executed
command result.
• _______ function is capable of reading a file into an array
• String values in PHP must be enclosed within________

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 107


Weekly Assignment

• Define PHP with its syntax.


• Explain variables & constants with example and code.
• What do you mean by data type, operator & expressions.
• Define control flow and decision making statements.
• What do you mean by functions, strings and arrays.
• Explain file & directory, and give commands for opening, closing, coping,
renaming and deleting a file.
• Give commands for creating or deleting folder, file uploading &
downloading.
• Introduce the session control with session functionality.
• What is a Cookie? Explain setting cookies with PHP.

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 108


Recap of Unit 5

• Discussed about the history of PHP language


• Discussed about various methods and function for file and
directory.
• Discussed the cookies in PHP.
• Discussed about session in PHP

12/13/2024 06/15/2022 Abdul Khalid WT Unit 1 109


Sessional Paper

12/13/2024 06/15/2022 Abdul Khalid WT Unit 1 110


Sessional Paper

12/13/2024 06/15/2022 Abdul Khalid WT Unit 1 111


Sessional Paper

12/13/2024 06/15/2022 Abdul Khalid WT Unit 1 112


Sessional Paper

12/13/2024 06/15/2022 Abdul Khalid WT Unit 1 113


Old Question Paper

12/13/2024 06/15/2022 Abdul Khalid WT Unit 1 114


Old Question Paper(cont..)

12/13/2024 06/15/2022 Abdul Khalid WT Unit 1 115


Old Question Paper(cont..)

12/13/2024 06/15/2022 Abdul Khalid WT Unit 1 116


Old Question Paper(cont..)

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 117


Old Question Paper(cont..)

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 118


Faculty Video Links, Youtube & NPTEL Video Links and Online
Courses Details
• https://www.youtube.com/watch?v=KMj49syT8JM&list=PLJ5C_6qdAvBHi
qw9Yc7-_vyfbBG1Bmfg_
• https://www.youtube.com/watch?v=biKUffL8cm4&list=PLJ5C_6qdAvBHiq
w9Yc7-_vyfbBG1Bmfg_&index=2
• https://www.youtube.com/watch?v=jyzBKgXxHww&list=PLJ5C_6qdAvBHi
qw9Yc7-_vyfbBG1Bmfg_&index=3
• https://www.youtube.com/watch?v=g6zGd6ycktY&list=PLo4R2IscWKdVqz
h_QECsxCq7QB1CUpYfi&index=1
• https://www.youtube.com/watch?v=g6zGd6ycktY&list=PLo4R2IscWKdVqz
h_QECsxCq7QB1CUpYfi&index=2
• https://www.youtube.com/watch?v=g6zGd6ycktY&list=PLo4R2IscWKdVqz
h_QECsxCq7QB1CUpYfi&index=3

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 119


Faculty Video Links, Youtube & NPTEL Video Links and Online
Courses Details
• https://www.youtube.com/watch?v=g6zGd6ycktY&list=PLo4R2IscWKdVqz
h_QECsxCq7QB1CUpYfi&index=4
• https://www.youtube.com/watch?v=g6zGd6ycktY&list=PLo4R2IscWKdVqz
h_QECsxCq7QB1CUpYfi&index=5
• https://www.youtube.com/watch?v=g6zGd6ycktY&list=PLo4R2IscWKdVqz
h_QECsxCq7QB1CUpYfi&index=6
• https://www.youtube.com/watch?v=g6zGd6ycktY&list=PLo4R2IscWKdVqz
h_QECsxCq7QB1CUpYfi&index=7
• https://www.youtube.com/watch?v=g6zGd6ycktY&list=PLo4R2IscWKdVqz
h_QECsxCq7QB1CUpYfi&index=8

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 120


Expected Questions for University Exam

1. Define PHP with its syntax.


2. Explain variables & constants with example and code.
3. What do you mean by data type, operator & expressions.
4. Define control flow and decision making statements.
5. What do you mean by functions, strings and arrays.
6. Explain file & directory, and give commands for opening, closing, coping,
renaming and deleting a file.
7. Give commands for creating or deleting folder, file uploading &
downloading.
8. Introduce the session control with session functionality.
9. What is a Cookie? Explain setting cookies with PHP.

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 121


References

TEXT BOOKS:
•(1.) Web Technologies, Black Book, Dreamtech Press.
•(2.) Internet and world wide web how to program, P.J. Deitel & H.M. Deitel, Pearson
•[3] Xavier, C,” Web Technology and Design”, New Age International.

REFERENCES:
• (1.) Ivan Bayross,”HTML, DHTML, JavaScript,Perl & CGI”, BPB Publication.
• (2.) Developing Web Applications, Ralph Moseley and M.T. Savaliya, Wiley-India
• (3.) Developing Web Applications in PHP and AJAX, Harwani, McGraw Hill.

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 122


THANKYOU

12/13/2024 Ankur Chaudhary Web Technology UNIT 5 123

You might also like