0% found this document useful (0 votes)
20 views139 pages

Chapter 01 PHP

The document provides an overview of PHP, including its history, advantages, disadvantages, and syntax. It covers essential topics such as variables, control statements, and the use of PHP in web development. PHP is highlighted as a powerful, open-source server-side scripting language suitable for creating dynamic websites and applications.

Uploaded by

zubiyaansari417
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)
20 views139 pages

Chapter 01 PHP

The document provides an overview of PHP, including its history, advantages, disadvantages, and syntax. It covers essential topics such as variables, control statements, and the use of PHP in web development. PHP is highlighted as a powerful, open-source server-side scripting language suitable for creating dynamic websites and applications.

Uploaded by

zubiyaansari417
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/ 139

Web based Application development with PHP

(22619)

Chapter 1
Expressions & Control statements in PHP

Chapter 01 1
Contents

History & Advantages of PHP, Syntax of PHP

Variables, Data types, Expressions, operators, constants

Decision making control statements- if, if-else, nested-if, switch, break,


continue statement

Loop control statements- while, do-while, for and foreach

Chapter 01 2
Chapter 01 3
Chapter 01 4
Chapter 01 5
Chapter 01 6
Chapter 01 7
Chapter 01 8
PHP

• PHP stands for Hypertext Pre-processor


• It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1994
• PHP is a Powerful ,Server side scripting language.
• It is used to develop Static websites or Dynamic websites or Web applications.
• PHP scripts can only be interpreted on a server that has PHP installed
• PHP is a general-purpose scripting language especially suited to web development.

Chapter 01 9
Chapter 01 10
History of PHP
• PHP was created by Rasmus Lerdorf in 1994 and was publicly released in June
1995.
• The PHP code is well organized and can be easily embedded into HTML code.
• It works on all major operating systems like Linux, Windows, Unix and Mac OS,
and it supports main web and enterprise servers like Apache, Netscape, Microsoft
IIS, etc. Moreover, it is easier to troubleshoot problems in PHP when compared to
other languages.
• For a web developer, designing a complex, yet attractive website in a short span
of time is a big challenge. This is where PHP frameworks prove to be useful.

Chapter 01 11
• PHP 3 – Hits the Big Time
• PHP 4 – Optimization, Scalability and More
• PHP 5 – Object Orientation, Error Handling, and XML
• PHP 7 – Makes Powering the web a whole lot better

Chapter 01 12
Uses of PHP

• It is used for create dynamic website.


• To Interacting with web server (Apache etc.)
• To interacting with any back-end / database server e.g. MySQL
• To interaction with the native file system of the OS
• To implement the business logical layers (one or more)
• It can Encrypt Data
• Access Cookies variable and set cookies
• Using php you can restrict user to access specific web page
• PHP usually used to output HTML code to the browser

Chapter 01 13
• Used for connecting web application with Database

• It is used to send and receive E-Mails.

• You can use PHP to find today's date, and then build a calendar for the month.
• If you host banner advertisements on your website, you can use PHP to rotate them
randomly.

• Using php you can count your visitors on your website.

Chapter 01 14
• You can use PHP to create a special area of your website for members.
• Using php you can create login page for your user.

• Using php you can 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.

• PHP performs system functions, i.e. from files on a system it can create, open,
read, write, and close them.
• It can handle forms, i.e. gather data from files, save data to a file.

Chapter 01 15
Chapter 01 16
Chapter 01 17
Chapter 01 18
Chapter 01 19
Chapter 01 20
Advantages of PHP

• Most important advantage of PHP is that it’s open source and freed from cost. It are
often downloaded anywhere and readily available to use for event of web
applications.
• It is platform independent. PHP based applications can run on any OS like UNIX, Linux
and windows, etc.
• Application can easily be loaded which are based on PHP and connected to database.
it’s mainly used due to its faster rate of loading over slow internet and speed than
another programing language.
• It has less learning curve, because it is straightforward and straightforward to use. If a
private knows C programming can easily work on PHP.
• It is more stable from a few years with assistance of providing continuous support to
various versions.

Chapter 01 21
• It helps in reusing an equivalent code and no got to write lengthy code and
sophisticated structure for event of web applications.
• It helps in managing code easily.
• It has powerful library support to use various function modules for data
representation.
• PHP’s built-in database connection modules help in connecting database easily
reduce trouble and time for development of web applications and content based
sites.
• Popularity of PHP gave rise to various community of developers, a fraction of which
may be potential candidates for hire.
• Flexibility makes PHP ready to effectively combine with many other programming
languages in order that the software package could use foremost effective technology
for every particular feature.

Chapter 01 22
Chapter 01 23
Disadvantages

• It is not that secure due to its open-source, because the ASCII text file are often easily
available.
• It is not suitable for giant content-based web applications.
• It has a weak type, which can cause incorrect data and knowledge to user.
• PHP frameworks got to learn to use PHP built-in functionalities to avoid writing
additional code.
• Using more features of PHP framework and tools cause poor performance of online
applications.
• PHP don’t allow change or modification in core behavior of online applications.

Chapter 01 24
• The PHP frameworks aren’t an equivalent in behavior so does their performance and
features.
• While PHP may be a powerful tool supported by an outsized community and plentiful
reference documentation, there are easier programming languages for web apps.
• It is widely believed by the developers that PHP features a poor quality of handling
errors. PHP lacks debugging tools, which are needed to look for errors and warnings.
PHP has less number of debugging tools in comparison to other programming
languages.
• It’s highly tough to manage because, it’s not competent modular. It already imitates
the features of Java language.

Chapter 01 25
Syntax of PHP
• 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!"

Chapter 01 26
<html>
<body>

<?php echo "Hello World!";

?>

</body>
</html>

Chapter 01 27
Chapter 01 28
• PHP statements end with a semicolon ( ; )

• There are 2 basic statements to output text with PHP :


echo & print

Chapter 01 29
Embedding PHP within HTML

<html>
<head>
<title>Simple PHP file</title>
</head>
<body>

<h1>
<?php echo "Hello World!";
?>
</h1>

</body>
</html>

Chapter 01 30
Chapter 01 31
Chapter 01 32
PHP echo & print

There are 2 ways to get output


 echo
 print

Chapter 01 33
Chapter 01 34
Chapter 01 35
Chapter 01 36
Chapter 01 37
Compare echo & print

Chapter 01 38
print_r() in PHP

• It is used to print human readable information about a variable

Chapter 01 39
Chapter 01 40
Variables in PHP

Chapter 01 41
Chapter 01 42
Chapter 01 43
Rules for declaring variables

Chapter 01 44
Chapter 01 45
Chapter 01 46
Chapter 01 47
Chapter 01 48
Chapter 01 49
Chapter 01 50
Chapter 01 51
Chapter 01 52
Chapter 01 53
Chapter 01 54
Chapter 01 55
Chapter 01 56
Chapter 01 57
Chapter 01 58
Chapter 01 59
Chapter 01 60
Chapter 01 61
Chapter 01 62
Chapter 01 63
Chapter 01 64
Chapter 01 65
Chapter 01 66
Chapter 01 67
Chapter 01 68
Chapter 01 69
Chapter 01 70
Chapter 01 71
Chapter 01 72
Chapter 01 73
Chapter 01 74
Chapter 01 75
Chapter 01 76
Chapter 01 77
Chapter 01 78
Chapter 01 79
Chapter 01 80
Chapter 01 81
Chapter 01 82
Chapter 01 83
Chapter 01 84
Chapter 01 85
Chapter 01 86
Chapter 01 87
Chapter 01 88
Chapter 01 89
Chapter 01 90
Chapter 01 91
Chapter 01 92
Chapter 01 93
Chapter 01 94
Chapter 01 95
Chapter 01 96
Chapter 01 97
Chapter 01 98
Chapter 01 99
Chapter 01 100
Chapter 01 101
Chapter 01 102
Chapter 01 103
Chapter 01 104
Chapter 01 105
Chapter 01 106
Chapter 01 107
Chapter 01 108
Chapter 01 109
Chapter 01 110
Chapter 01 111
Chapter 01 112
Chapter 01 113
Chapter 01 114
Chapter 01 115
Chapter 01 116
Chapter 01 117
Break & continue statement

Chapter 01 118
Chapter 01 119
Chapter 01 120
Chapter 01 121
Chapter 01 122
Chapter 01 123
Chapter 01 124
Chapter 01 125
Chapter 01 126
Chapter 01 127
Chapter 01 128
Chapter 01 129
Chapter 01 130
Chapter 01 131
Chapter 01 132
Chapter 01 133
Chapter 01 134
Chapter 01 135
Chapter 01 136
Chapter 01 137
Chapter 01 138
Thank You

Chapter 01 139

You might also like