yasar hussain malik - niste. php origins rasmus lerdorf php originally abbreviation for ‘personal...
TRANSCRIPT
Yasar Hussain Malik - NISTE
PHP OriginsRasmus Lerdorf
PHP originally abbreviation for ‘Personal Home Pages’, now ‘PHP Hypertext Processor’
Other key developers: Zeev Surashi and Andi Gutmans
Open Source
Brief History of PHP
Brief History of PHP
As of August 2004, PHP is used on 16,946,328 Domains, 1,348,793 IP Addresses http://www.php.net/usage.php This is roughly 32% of all domains on the web.
Brief History of PHP
As of April 2007, PHP is used on 20,917,850 Domains
Open SourceIn general, open source refers to any program whose source code is made available for use or modification as users or other developers see fit. Open source software is usually developed as a public collaboration and made freely available.
Open Source is a certification mark owned by the Open Source Initiative (OSI). Developers of software that is intended to be freely shared and possibly improved and redistributed by others can use the Open Source trademark if their distribution terms conform to the OSI's Open Source Definition. To summarize, the Definition model of distribution terms require that:
The software being distributed must be redistributed to anyone else without any restriction.
The source code must be made available (so that the receiving party will be able to improve or modify it).
The license can require improved versions of the software to carry a different name or version from the original software.
Why is PHP used?Cross PlatformRuns on almost any Web server on several operating systems.One of the strongest features is the wide range of supported databases
Web Servers: Apache, Microsoft IIS, Caudium, Netscape Enterprise Server
Operating Systems: UNIX (HP-UX,OpenBSD,Solaris,Linux), Mac OSX, Windows NT/98/2000/XP/2003
Supported Databases: Adabas D, dBase,Empress, FilePro (read-only), Hyperwave,IBM DB2, Informix, Ingres, InterBase, FrontBase, mSQL, Direct MS-SQL, MySQL, ODBC, Oracle (OCI7 and OCI8), Ovrimos, PostgreSQL, SQLite, Solid, Sybase, Velocis,Unix dbm
…Why is PHP used?3. Cost Benefits
PHP is free. Open source code means that the entire PHP community will contribute towards bug fixes. There are several add-on technologies (libraries) for PHP that are also free.
PHP
Software Free
Platform Free (Linux)
Development Tools Free
PHP Coder, jEdit
Scripting languages
PHP detailsProcedural language
Compare with Javascript which is event-drivenC-like syntax - { } ;Extensive Function LibraryGood Web-server integration
Script embedded in HTMLEasy access to form data and output of HTML
pagesNot fully object-oriented
Java is fully object oriented – all functions have to be in a class
In PHP, classes are additional but quite simple to use
Getting Started1. How to escape from HTML and enter PHP mode
PHP parses a file by looking for one of the special tags thattells it to start interpreting the text as PHP code. The parser then executes all of the code it finds until it runs into a PHP closing tag.
Starting tag Ending tag Notes
<?php ?> Preferred method as it allows the use of PHP with XHTML
<? ?> Not recommended. Easier to type, but has to be enabled and may conflict with XML
<script language="php"> ?> Always available, best if used when FrontPage is the HTML editor
<% %> Not recommended. ASP tags support was added in 3.0.4
<?php echo “Hello World”; ?>
PHP CODE HTMLHTML
PHP and HTMLHTML-embedded
PHP scripts are essentially HTML pages with the occasional section of PHP script.
PHP script is enclosed in the tag pair: <?php print date(“H:I”) ?>
ExamplesBenefits: - Any changes to header or footer only require editing of a single file. This reduces the amount of work necessary for site maintenance and redesign. - Helps separate the content and design for easier
maintenance
Page 1Content
Page 5Content
Page 3Content
Page 2Content
Page 4Content
Header
Footer
C-like languageFree format - white space is ignored Statements are terminated by semi-colon ; Statements grouped by { … } Comments begin with // or a set of comments /* */ Assignment is ‘=’: $a=6Relational operators are ,< , > == ( not a single equal) Control structures include if (cond) {..} else { }, while
(cond) { .. } , for(sstartcond; increment; endcond) { } Arrays are accessed with [ ] : $x[4] is the 5th element of
the array $x – indexes start at 0 Functions are called with the name followed by arguments
in a fixed order enclosed in ( ) : substr(“fred”,0,2) Case sensitive - $red is a different variable to $RED
Function libraryBasic tasks
String Handling Mathematics – random numbers, trig functions.. Regular Expressions Date and time handling File Input and Output
And more specific functions for-Database interaction –
MySQL, Oracle, Postgres, Sybase, MSSQL .. Encryption Text translation Spell-checking Image creation XML
String HandlingString 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”
Within single quoted strings, interpolation doesn’t occur
Strings are concatenated (joined end to end) with the dot operator “key”.”board” == “keyboard”
Standard functions exist: strlen(), substr() etc Values of other types can be easily converted to and
from strings – numbers implicitly converted to strings in a string context.
Regular expressions be used for complex pattern matching.
3 Tier architecture
PHP script
Remote services
Web Server (Apache, IIS)
Browser(IE, FireFox,
Opera)
Desktop (PC or MAC)
Database
Database Server
SQL
Client application
HTTP
HTML
Web Service
tables
DHTML
vision
touch
voice