22-12-2010, 04:47 PM
Prepared by:Srinivas H.N
[attachment=7539]
History of PHP
Created by Rasmus Lerdorf in 1995 for tracking access to his resume
Originally a set of Perl scripts known as the “Personal Home Page” tools
Added a forms interpreter and released as PHP/FI: includes Perl-like variables, and HTML embedded syntax
What is PHP?
PHP stands for "Personal Home Page Hypertext Preprocessor”
PHP is a simple yet powerful open source scripting language for creating dynamic web content in Linux and windows.
Easy to create Dynamic web pages in Linux.
Data Abstraction .
A language that combines elements of Perl, C, and Java
An embedded scripting language for HTML like ASP or JSP
Data Abstraction.
PHP does not have a uniform method for accessing database.
Specialized function for each database PHP is able to connect to.
Benefits
allows you to optimize your database code
Core engine (Zend)
Responsible for parsing PHP code,and as such defines the syntax of the programming languages.
Server API (SAPI)
Handles communication and interface with the web server.
Easy to integrate PHP with other server E.g use PHP as an ISAPI module for internet information server(IIS)
Function modules: MySql,XML,IMAP,and so on..
Well documented
Large Library
Good database interaction
Platform Independent.
Since it is a scripting language it can also be use for stand alone applications.
PHP in HTML
<? // Some code ?>
PHP in XML
<?php // Some code here ?php>
PHP in ASP
<% //some codes %>
Code Portability:
if( ereg("WIN", PHP_OS) ){ $ApachePath = “C:/Program Files/Apache Group/Apache”; $ConfigPath = ”$ApachePath/htdocs/conf"; $DataPath = "$ApachePath/htdocs/data";}$ConfigFile = "$ConfigPath/paperwork.conf";$CountryList = "$DataPath/countries.txt";$StateAbbrList = "$DataPath/usstateabbrs.txt";$StateNameList = "$DataPath/usstatenames.txt";
Code Portability
if( PHP_OS == "Linux" ){ $ConfigPath = "/var/www/conf"; $DataPath = "/var/www/data";}
The different field where PHP can be used are
Languages (WWW-form Handling) basics
Databas connections
Fun Stuff
generating images data
Cookies
Sessions
Web Servers & Clients :
Browser is a web client
It sends requests to a server
Server responds with the text of the file
Browser formats the text and displays the file.
A cookie is a small file that the server embeds on the user’s computer .
Example:
<?php
setcookie(“uname,$name,time);
?>
<html>
<body>
<p> Cookie is set</p>
</body></html>
PHP uses built in functions in order to connect to database
Example:
<?php
require_once(“Domain name”);
$dbh=Connect(“Par_database);
?>
In PHP, SQL statements can be used to query the database.
Results are set equal to a variable which is of array type
Example:
//below line is the actual query submitted to the database
$statement = "SELECT call_no, title, author, publisher, type_of_material, checked_in, due_back, id, email FROM itl_library_records WHERE call_no ILIKE '$call_no%' ORDER BY call_no";
<?
//query result stored in "$result" variable
$result = $dbh->query($statement);
While($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
{
print(“$row[0]”); //can also be written as … echo “$row[0]”;print(“$row[1]”);
}
• December 2004 survey at
http://securityspaces_survey/data/man.2004
54% PHP
15% FrontPage
9% Perl
1% Python
PHP is a melting pot of cultures .web designers
appreciates its accessibility and convenience, while
programmers appreciate its flexibility and speed.