2. INTRODUCTION
• It is an interpreted, server-side scripting language.
• Originally designed for web development.
• Similar languages are Perl, ASP.NET, Ruby, JSP (Java
Server Pages)
• Embedded into HTML
• Can use DB (MySQL, Oracle, Microsoft SQL, Postgre
SQL)
5. HISTORY
• Began in 1994 by Rasmus Lerdorf
• Soon he named PHP/FI to build simple, dynamic web
applications.
• In 1995 -the release of PHP/FI as "Personal Home Page
Tools (PHP Tools) version 1.0".
• In 1997 Zeev Suraski and Andi Gutmans rewrote
the parser and formed the base of PHP 3, changing the
name PHP: Hypertext Preprocessor.
• On May,2000, PHP 4 was released,
• On July , 2004, PHP 5 was released, powered by the new
Zend Engine II.
• In 2008 PHP 5 became the only stable version under
development.
• Finally after a vote the current version released in 2014 .
7. SCRIPTING LANGUAGE
• A scripting language is:
– cross-platform since interpreter is easy to port
– implicit variable declaration
– compiled on demand
– Extending
– Glue programming
18. VARIABLES IN PHP
• All variables in PHP start with a $ sign symbol.
• Variables may contain strings, numbers, or arrays.
<html>
<body>
<?php $txt="Hello World"; echo $txt;
?>
</body>
</html>
19. DATA TYPES
• String
$name=“x”
– 'My name is x.'
– "My name is $name."
• Boolean
• Integer
• Floating point
• Array
– $a=array("tokyo", "hanoi", "london")
– $a=array("japan" => "tokyo", "vietnam" =>
"hanoi", "england" => "london")
– $a[2]
– $a["vietnam"]
20. STRING HANDLING
• String literals (constants) enclosed in double quotes “ ”
or single quotes ‘ ’
• Within “”, variables are replaced by their value: – called
variable interpolation. “My name is $name, I think”
• Strings are concatenated (joined end to end) with the
dot operator “key”.”board” == “keyboard”
21. THE IF...ELSE STATEMENT
Syntax
if (condition)
code to be executed if condition is true;
else
code to be executed if condition is false;
22. Syntax
switch (expression)
{
case label1: code to be executed if expression =
label1; break;
case label2: code to be executed if expression =
label2; break;
default: code to be executed if expression
is different from both label1
and label2;
}
THE SWITCH STATEMENT
24. STATE MANAGEMENT
• It is used to help web
applications to maintain
their state across several
HTTP requests when
needed.
• Cookies
• Session
25. SESSION
• Better option of cookie
• Store information about a user. They
are available only for a particular
application and hold information of
only one single user.
32. • session_destroy();
• unset();
<?php start_session();
$_SESSION[‘user_name’]=
if(isset($_POST[“lgt_btn"]))
unset($_SESSION[‘user_name’]);
?> Name of the
Logout button
33.
34. FEATURES OF PHP
– Support for MySQL, Oracle, dbm, DB2,
PostgreSQL
– Can connect to any database which
provides an ODBC driver (Open Database
Connectivity Standard) – e.g. MS Access.
– Supported on Windows, Mac OS X, other
Unix-like systems (e.g. Linux).
– Similar syntax and features as C++ and Java.
– PHP designer,Wampp/Xampp are free of
cost.