1 PHP

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 25

PHP

What is PHP

 The PHP Hypertext Preprocessor (PHP) is a programming language


that allows web developers to create dynamic content that
interacts with databases. PHP is basically used for developing web
based software applications.
 The basic syntax of PHP is similar to C, Java, and Perl, and is easy to
learn. PHP is used for creating interactive and dynamic web pages
quickly, but you can do much more with PHP.
 It is a cross-platform, HTML-embedded server-side scripting
language and is especially suited for web development.
 Server-side means that PHP scripts execute on the Web server, not
within the browser on your local machine.
 Cross-platform means that PHP scripts can run on many different
operating systems and Web servers. PHP is available for the two
most popular Web server configurations IIS and Apache.
 HTML embedded scripting language means that PHP statements
and commands are actually embedded in your HTML documents.
When the Web server sees the PHP statements in the Web page, the
server executes the statements and sends the resulting output along
with the rest of the HTML. PHP commands are parsed by the server
much like Active Server Pages or Cold Fusion tags.
History of PHP

 PHP started out as a small open source project that evolved as


more and more people found out how useful it was. Rasmus Lerdorf
unleashed the first version of PHP way back in 1994.
PHP Versions

Supported
Version Release date Description
until
Officially called "Personal Home
1.0 8 June 1995 Page". This is the first version of
"PHP".

1 November
2.0 Officially called "PHP/FI 2.0".
1997

20 October Development moves from one


3.0 6 June 1998
2000 person to multiple developers.
Added more advanced two-
23 June stage parse/execute tag-
4.0 22 May 2000
2001 parsing system called the Zend
engine.
10 Introduced "superglobals"
12 March
4.1 December Variables ($_GET, $_POST,
2002
2001 $_SESSION, etc.)
Disabled register_globals. Data received over the network is not directly inserted into
4.2 22 April 2002 6 September 2002
the global namespace, closing possible security holes in applications.

27
4.3 December 31 March 2005 Introduced the command-line interface (CLI), to supplement the CGI.
2002
4.4 11 July 2005 7 August 2008 Fixed a memory corruption bug
5.0 13 July 2004 5 September 2005 Zend Engine II with a new object model.

24
Performance improvements with introduction of compiler variables. Added PHP Data
5.1 November 24 August 2006
Objects (PDO) as a consistent interface for accessing databases.
2005

2 November
5.2 6 January 2011 Enabled filter extension. JSON Support.
2006

Namespace support, late static bindings, jumping statement (goto), garbage


5.3 30 June 2009 14 August 2014 collection, improved Windows support, sqlite3, mysqlnd as a replacement for libmysql
as underlying library for the extensions that work with MySQL.
Trait support, short array syntax support. Removed items: register_globals, safe_mode,
5.4 1 March 2012 3 September 2015 allow_call_time_pass_reference, session_register(), session_unregister() and session_is_registered().
Several improvements to existing features, performance and reduced memory requirements.

5.5 20 June 2013 10 July 2016 Support for generators, finally blocks for exceptions handling.

Constant scalar expressions, argument unpacking, new exponentiation operator, extensions of the use
5.6 28 August 2014 31 December 2018
statement for functions and constants, and other smaller improvements.

6.x Not released Abandoned version of PHP that planned to include native Unicode support.

64-bit integer support on Windows, uniform variable syntax, return type declarations, scalar type
7.0 3 December 2015 3 December 2018 (integer, float, string and boolean) declarations, <=> 'spaceship' three-way comparison operator and
shorthand syntax for importing multiple items from a namespace.
void return type,
7.1 1 December 2016 1 December 2019 class constant
visibility modifiers.
Counting of non-
7.2 30 November 2017 30 November 2020
countable objects.
support for
reference
7.3 6 December 2018 6 December 2021 assignment and
array deconstruction
with list()
 PHP stands for HyperText Preprocessor.
 PHP files can contain text, HTML, CSS, JavaScript, and PHP code
 PHP files have extension ".php"
 PHP code are executed on the server so you need web browser to
execute php code
 It is an interpreted language, i.e. there is no need for compilation.
 It is a server side scripting language.
 It is faster than other scripting language e.g. asp and jsp.
Advantage of php

 It is open source.
 Widly used in all over the world
 To execute php code no need compiler.
 PHP costs nothing, it is free to download and use.
 PHP is a server-side scripting language and is used for websites and the
web applications.
 PHP scripts are executed on the server.
 PHP supports a wide range of databases.
 PHP runs on various platforms like Linux, Windows, Unix etc.
 PHP supports most web servers (for example Apache, IIS).
 PHP converses with several network protocols.
Features of PHP
 It is most popular and frequently used world wide scripting language, the main reason of
popularity is; It is open source and very simple.
 Simple
 Faster
 Interpreted
 Open Source
 Case Sensitive
 Simplicity
 Efficiency
 Platform Independent
 Security
 Flexibility
 Familiarity
 Error Reporting
 Loosely Typed Language
 Real-Time Access Monitoring
 Simple
 It is very simple and easy to use, compare to other scripting language it
is very simple and easy, this is widely used all over the world.
 Interpreted
 It is an interpreted language, i.e. there is no need for compilation.
 Faster
 It is faster than other scripting language e.g. asp and jsp.
 Open Source
 Open source means you no need to pay for use php, you can free
download and use.
 Platform Independent
 PHP code will be run on every platform, Linux, Unix, Mac OS X, Windows.
 Case Sensitive
 PHP is case sensitive scripting language at time of variable declaration.
In PHP, all keywords (e.g. if, else, while, echo, etc.), classes, functions,
and user-defined functions are NOT case-sensitive.
 Error Reporting
 PHP have some predefined error reporting constants to generate a
warning or error notice.
 Real-Time Access Monitoring
 PHP provides access logging by creating the summary of recent
accesses for the user.
 Loosely Typed Language
 PHP supports variable usage without declaring its data type. It will be
taken at the time of the execution based on the type of data it has on
its value.
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
 Used for connect web application with DataBase
 It is used for 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.
 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.
 It can encrypt data.
 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.
Why use php

 It runs on different platforms such as Windows, Linux, Unix, etc.


 This language is very simple to learn and runs efficiently on the server
side.
 It is compatible with almost all servers used today,such as Apache, IIS,
etc.
 It supports many databases such as MySQL, Oracle, PostgreSQL etc.
 It is perfectly suited for Web development and can be embedded
directly into the HTML code.
 PHP can also be used to create dynamic web pages.
 It is often used together with Apache (web server) on various operating
systems. It can be also used with Microsoft's IIS on Windows.
 It is open source and it is free downloadable
Basic Syntax of PHP

 You can run php code on any web browser. PHP script is executed
on the server, and the plain HTML result is sent back to the browser.
Basic Syntax of PHP
 PHP code is start with <?php and ends with ?>
 Every PHP statements end with a semicolon (;).
 PHP code save with .php extension.
 PHP contain some HTML tag and PHP code.
 You can place PHP code any where in your document.
Simple Example of
PHP

 Here we write very simple


code by using only echo
command and php file
save with .php extension.
PHP Case Sensitivity

 In PHP, all keywords (e.g. if, else, while, echo, etc.), classes,
functions, and user-defined functions are NOT case-sensitive.
However all variable names are case-sensitive.
Example: Echo Keyword
can be written in following
ways: Example: Variable

<?php <?php
echo "echo keyword in lower letter <br>"; $name="Rasmus Lerdorf";
Echo "Echo keyword in sentance case $dob="22 November 1968";
<br>";
$YEAR="1995";
EcHo "EcHo keyword in mixed case <br>";
echo "PHP Developed By $name in $year
ECHO "ECHO keyword in capital case <br>";
<br>";
echo "DOB of $NAME is $dob";
?>
?>
Output:
Output:
echo keyword in lower letter
Echo keyword in sentance case PHP Developed By Rasmus Lerdorf in
EcHo keyword in mixed case DOB of is 22 November 1968
ECHO keyword in capital

Comments in PHP

 A comment in PHP code is a line that is not read/executed as part


of the program. Its only purpose is to be read by someone who is
looking at the code.
 A comment is simply text that is ignored by the PHP engine.
 The purpose of comments is to make the code more readable.
 Comments can be used to:
 Let others understand what you are doing
 Remind yourself of what you did - Most programmers have experienced
coming back to their own work a year or two later and having to re-
figure out what they did. Comments can remind you of what you were
thinking when you wrote the code
 PHP support single-line as well as multi-line comments. To write a
single-line comment either start the line with either two slashes (//) or
a hash symbol (#).
 For Example
<?php
// This is a single line comment
# This is also a single line comment
echo "Hello, world!";
?>
 To write multi-line comments, start the comment with a slash
followed by an asterisk (/*) and end the comment with an asterisk
followed by a slash (*/), like this:
<?php
/* This is a multiple line comment block that spans across more than
one line */
echo "Hello, world!";
?>

You might also like