History of PHP - II PHP 3.0 provides a concrete infrastructure for different databases, protocols, and APIs to the end users along with the support for object oriented syntax PHP 3.0
Trang 1Introduction to PHP
Session 1
Trang 2 Discuss the history of PHP
Identify the need for PHP
List the PHP tools
Write a simple PHP script
Trang 3History of PHP - I
An advance product of PHP/FI
PHP/FI stands for Personal Home Page/Forms Interpreter
Rasmus Lerdorf created PHP/FI in the year 1995
PHP/FI got advanced to PHP/FI 2.0 in the year 1997
Andi Gutmans and Zeev Surakshi advanced PHP/FI
2.0 to PHP 3.0 in the year 1997 This was the first version of recent PHP
Trang 4History of PHP - II
PHP 3.0 provides a concrete infrastructure for different databases, protocols, and APIs to the end users along with the support for object oriented syntax
PHP 3.0 got advanced to PHP 4.0 in the year 1998
PHP 4.0 includes supportive features for more Web servers, HTTP sessions, output buffering, and security while handling user inputs
This is the latest version of PHP
Trang 5Need for PHP
client-side GUI applications that can operate on any
platform
access, and graphics
Trang 6PHP tools and setup - I
Uses for developing and designing a web pages
Contains all the supporting features for the fast developments of
the web sites These tools are basically the programming text
editors
The tools are:
PHPEd – Helps a developer in developing applications by
supporting PHP scripts and its syntaxes It is freely available
to the users It is available with version 3.3
PHPDebugger DBG – Helps the PHP scripts to get executed
in steps It helps to trace out the errors in scripts This tool is
freely available to the users Its current version is 2.11.23
Trang 7PHP tools and setup - II
the execution of the scripts It is freely available Its
updated version is 3.1 The main functionality of this tool
is that it does not allow the document to get corrupted
available with 2.0 versions
processing a file The working of this tool depends on the
platform where the PHP is working It is freely available
for users Its updated version is 1.0rc2
Trang 8PHP tools and setup - III
available for the users It is an Integrated Development
Environment that includes all functionalities for
developing dynamic web sites
Its latest version is 0.2.2 It works with the free availability for the users This tool is built on eclipse platform An
eclipse platform is a tool platform for open source IDE
PHP Its latest version is 1.3 that is freely available to the
users This tool is a combination of Dreamweaver software with Microsoft Visual studio software
Trang 9PHP tools and setup - IV
Simplewire PHP SMS Software Development kit – Works
with the wireless messaging network to send SMS to mobile
phones It is freely available in 2.3.0 version
Quanta Plus Web Development Environment – Uses 2.0
version of tool It is freely available to the users It is a web
development tool
K PHP Develop – Supports MySQL as a database server It is freely available with 0.1.6 version of the software It has
different modules such as server, server setup, clients and
plugins
Gedit – Uses for writing PHP scripts It gets installed by
default while installing Linux It is just like a notepad of
windows
Trang 10Writing a Simple PHP
script
Starts with <?php tag and ends with the ?> tag
Scripts are embedded in the BODY tag of the HTML file
Saves with an extension, php under the
/var/www/html directory
For example, display a simple text in the browser
Trang 11Example for Simple PHP
Script
Enter the PHP codes in gedit text editor
<HTML>
<BODY>
<?php
echo “Hello Everybody”;
?>
</BODY>
</HTML>
Trang 12Output of the PHP Script
Enter http://localhost/stringdisp.php in
the address bar The output appears, as shown in the
figure
Trang 13Using PHP to generate
HTTP headers
HTTP is HyperText Transfer Protocol
It is a network transmission protocol
Uses with the help of TCP/IP protocol
Divides into three parts namely, request and response line, HTTP header, and the body of the protocol
Trang 14About HTTP header
the application that will be displayed on the
browser
on the response line
entity, and request/response
Trang 15Using header() function
Passes the HTTP commands to the server through
the HTTP protocols using the header()
function
Syntax for using the simple header() function is:
void header (‘string string’)
Where,
for the server The whole string is enclosed in the single
quotes
Trang 16Example using header()
function
For example, use an authenticating string in the
header() function
<?php
header(‘WWW-Authenticate:
Negotiate’);
?>
Trang 17Using options of header()
function
The syntax for using header() function with http_response_code option is:
void header (http_response_code)
Where,
http_response_code - Shows the response of the web server on any request It shows the response like status or the location of the client
Trang 18Example using the option
For example, show the location of the client
<?php
header(“Location: http://www.msn.com”); exit;
?>
Trang 19developing dynamic web pages and embedded in HTML tags
also executed from the command line to make client-side GUI applications
PDF and HTML formats
tag These scripts are embedded in the HTML tags
designing web pages Gedit is the most popular text editor
used for programming on Linux platform