SlideShare a Scribd company logo
1 of 10
Introduction to PHP
PHP Origins
Rasmus Lerdorf (born Greenland, ed Canada)

PHP originally abbreviation for ‘Personal Home Pages’,
  now ‘PHP Hypertext Processor’

Other key developers: Zeev Surashi and Andi Gutmans
  (Israel)

Open Source

PHP version 4.4.3 current at UWE
Due to upgrade to PHP 5
Scripting languages
• A scripting language is:
   –   often evolved not designed
   –   cross-platform since interpreter is easy to port
   –   designed to support a specific task – PHP -> Web support
   –   un-typed variables (but values are typed)
   –   implicit variable declaration
   –   implicit type conversion
   –   stored only as script files
   –   compiled on demand
   –   may run on the server (PHP) or the client (Javascript)
• What design and development are involved in using a
  scripting language like PHP for development in place of
  a compiled language (Java in JSP, .NET)?
PHP details
• Procedural language
   – Compare with Javascript which is event-driven
• C-like syntax - { } ;
• Extensive Function Library
• Good Web-server integration
   – Script embedded in HTML
   – Easy access to form data and output of HTML pages
• Not 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
PHP and HTML
• HTML-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”) ?>
C-like language
•   Free 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=6
•   Relational 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
•   Associative Arrays (hash array in Perl, dictionary in Java) are
    accessed in the same way: $y[“fred”]
•   Functions are called with the name followed by arguments in a fixed
    order enclosed in ( ) : substr(“fred”,0,2)
•   Case sensitive - $fred is a different variable to $FRED
Function library
• Basic 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 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”
• 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(+1) Tier architecture
 voice
             DHTML

  touch       Browser       HTTP                         SQL
           (IE, FireFox,                PHP script               Database
              Opera)
                                      Web Server                 Database
  vision                   HTML       (Apache, IIS)     tables
                                                                  Server
             Desktop
           (PC or MAC)


SMS
                                                      Web Service
           SMS system
                              Client application



                                           Remote services
Learning PHP
• Start with just the basics, installing a script
  to output an HTML page
• Understand how PHP supports interaction
  with the Browser or other clients
• Understand how PHP supports integration
  with databases – MySQL
• Understand how PHP supports integration
  with other applications – Web services

More Related Content

Viewers also liked

Searching for Medical Information
Searching for Medical InformationSearching for Medical Information
Searching for Medical InformationRonan Concannon
 
進擊的UX - UX and rapid prototyping @ 元智
進擊的UX - UX and rapid prototyping @ 元智進擊的UX - UX and rapid prototyping @ 元智
進擊的UX - UX and rapid prototyping @ 元智伯方 蘇
 
Brand trends shortened version july 2010
Brand trends shortened version july 2010Brand trends shortened version july 2010
Brand trends shortened version july 2010Polestar Communications
 
Pz Bijeenkomst 15 Jan
Pz Bijeenkomst 15 JanPz Bijeenkomst 15 Jan
Pz Bijeenkomst 15 Jantriesren
 
Las Varices . Dr Hugo Navas Farfán
Las Varices . Dr Hugo Navas FarfánLas Varices . Dr Hugo Navas Farfán
Las Varices . Dr Hugo Navas FarfánHugo Navas
 
Chapter 21 Brief Myths
Chapter 21  Brief MythsChapter 21  Brief Myths
Chapter 21 Brief Mythsgueste81430f
 
進擊的UX - rapid prototyping @ 新北市企業產經大學
進擊的UX - rapid prototyping @ 新北市企業產經大學進擊的UX - rapid prototyping @ 新北市企業產經大學
進擊的UX - rapid prototyping @ 新北市企業產經大學伯方 蘇
 
The core of innovation: Empathy and Experiment
The core of innovation: Empathy and ExperimentThe core of innovation: Empathy and Experiment
The core of innovation: Empathy and Experiment伯方 蘇
 

Viewers also liked (9)

Searching for Medical Information
Searching for Medical InformationSearching for Medical Information
Searching for Medical Information
 
進擊的UX - UX and rapid prototyping @ 元智
進擊的UX - UX and rapid prototyping @ 元智進擊的UX - UX and rapid prototyping @ 元智
進擊的UX - UX and rapid prototyping @ 元智
 
Brand trends shortened version july 2010
Brand trends shortened version july 2010Brand trends shortened version july 2010
Brand trends shortened version july 2010
 
Pz Bijeenkomst 15 Jan
Pz Bijeenkomst 15 JanPz Bijeenkomst 15 Jan
Pz Bijeenkomst 15 Jan
 
Las Varices . Dr Hugo Navas Farfán
Las Varices . Dr Hugo Navas FarfánLas Varices . Dr Hugo Navas Farfán
Las Varices . Dr Hugo Navas Farfán
 
Luxury v2
Luxury v2Luxury v2
Luxury v2
 
Chapter 21 Brief Myths
Chapter 21  Brief MythsChapter 21  Brief Myths
Chapter 21 Brief Myths
 
進擊的UX - rapid prototyping @ 新北市企業產經大學
進擊的UX - rapid prototyping @ 新北市企業產經大學進擊的UX - rapid prototyping @ 新北市企業產經大學
進擊的UX - rapid prototyping @ 新北市企業產經大學
 
The core of innovation: Empathy and Experiment
The core of innovation: Empathy and ExperimentThe core of innovation: Empathy and Experiment
The core of innovation: Empathy and Experiment
 

More from AP DealFlow

10208308 republic-of-sino-burma
10208308 republic-of-sino-burma10208308 republic-of-sino-burma
10208308 republic-of-sino-burmaAP DealFlow
 
Social time currency v5
Social time currency v5Social time currency v5
Social time currency v5AP DealFlow
 
Social credit system e2 x
Social credit system   e2 xSocial credit system   e2 x
Social credit system e2 xAP DealFlow
 
Hk city i apps for startups-ge2304
Hk city i apps for startups-ge2304Hk city i apps for startups-ge2304
Hk city i apps for startups-ge2304AP DealFlow
 
Oceanethix strategic plan china owned 2008 to 2030 update 081211
Oceanethix strategic plan china owned 2008 to 2030 update 081211Oceanethix strategic plan china owned 2008 to 2030 update 081211
Oceanethix strategic plan china owned 2008 to 2030 update 081211AP DealFlow
 
Apstartup crowdfunding ver3
Apstartup crowdfunding ver3 Apstartup crowdfunding ver3
Apstartup crowdfunding ver3 AP DealFlow
 
Social credit system
Social credit systemSocial credit system
Social credit systemAP DealFlow
 
NASC presentation
NASC presentationNASC presentation
NASC presentationAP DealFlow
 
Apps for startups concept
Apps for startups conceptApps for startups concept
Apps for startups conceptAP DealFlow
 
Apstartup europe expansion ver4
Apstartup europe expansion ver4Apstartup europe expansion ver4
Apstartup europe expansion ver4AP DealFlow
 
A wee story the golden sea
A wee story  the golden seaA wee story  the golden sea
A wee story the golden seaAP DealFlow
 
Parliamentary committee250407
Parliamentary committee250407Parliamentary committee250407
Parliamentary committee250407AP DealFlow
 
Aspirations of China’s “Second-Tier” Cities
Aspirations of China’s  “Second-Tier” CitiesAspirations of China’s  “Second-Tier” Cities
Aspirations of China’s “Second-Tier” CitiesAP DealFlow
 
sparkinoo_elemooni.pptx
sparkinoo_elemooni.pptxsparkinoo_elemooni.pptx
sparkinoo_elemooni.pptxAP DealFlow
 
Apstartup crowdfunding ver2
Apstartup crowdfunding ver2 Apstartup crowdfunding ver2
Apstartup crowdfunding ver2 AP DealFlow
 
Vita genes test brochure
Vita genes test brochureVita genes test brochure
Vita genes test brochureAP DealFlow
 
Vita genes ppt 20120802
Vita genes ppt 20120802Vita genes ppt 20120802
Vita genes ppt 20120802AP DealFlow
 
Vitargent introduction20130507
Vitargent introduction20130507Vitargent introduction20130507
Vitargent introduction20130507AP DealFlow
 
Cocoon case smallsize
Cocoon case smallsizeCocoon case smallsize
Cocoon case smallsizeAP DealFlow
 
Gcp solar introduction v2
Gcp solar   introduction v2Gcp solar   introduction v2
Gcp solar introduction v2AP DealFlow
 

More from AP DealFlow (20)

10208308 republic-of-sino-burma
10208308 republic-of-sino-burma10208308 republic-of-sino-burma
10208308 republic-of-sino-burma
 
Social time currency v5
Social time currency v5Social time currency v5
Social time currency v5
 
Social credit system e2 x
Social credit system   e2 xSocial credit system   e2 x
Social credit system e2 x
 
Hk city i apps for startups-ge2304
Hk city i apps for startups-ge2304Hk city i apps for startups-ge2304
Hk city i apps for startups-ge2304
 
Oceanethix strategic plan china owned 2008 to 2030 update 081211
Oceanethix strategic plan china owned 2008 to 2030 update 081211Oceanethix strategic plan china owned 2008 to 2030 update 081211
Oceanethix strategic plan china owned 2008 to 2030 update 081211
 
Apstartup crowdfunding ver3
Apstartup crowdfunding ver3 Apstartup crowdfunding ver3
Apstartup crowdfunding ver3
 
Social credit system
Social credit systemSocial credit system
Social credit system
 
NASC presentation
NASC presentationNASC presentation
NASC presentation
 
Apps for startups concept
Apps for startups conceptApps for startups concept
Apps for startups concept
 
Apstartup europe expansion ver4
Apstartup europe expansion ver4Apstartup europe expansion ver4
Apstartup europe expansion ver4
 
A wee story the golden sea
A wee story  the golden seaA wee story  the golden sea
A wee story the golden sea
 
Parliamentary committee250407
Parliamentary committee250407Parliamentary committee250407
Parliamentary committee250407
 
Aspirations of China’s “Second-Tier” Cities
Aspirations of China’s  “Second-Tier” CitiesAspirations of China’s  “Second-Tier” Cities
Aspirations of China’s “Second-Tier” Cities
 
sparkinoo_elemooni.pptx
sparkinoo_elemooni.pptxsparkinoo_elemooni.pptx
sparkinoo_elemooni.pptx
 
Apstartup crowdfunding ver2
Apstartup crowdfunding ver2 Apstartup crowdfunding ver2
Apstartup crowdfunding ver2
 
Vita genes test brochure
Vita genes test brochureVita genes test brochure
Vita genes test brochure
 
Vita genes ppt 20120802
Vita genes ppt 20120802Vita genes ppt 20120802
Vita genes ppt 20120802
 
Vitargent introduction20130507
Vitargent introduction20130507Vitargent introduction20130507
Vitargent introduction20130507
 
Cocoon case smallsize
Cocoon case smallsizeCocoon case smallsize
Cocoon case smallsize
 
Gcp solar introduction v2
Gcp solar   introduction v2Gcp solar   introduction v2
Gcp solar introduction v2
 

IntroductiontoPHP.ppt

  • 2. PHP Origins Rasmus Lerdorf (born Greenland, ed Canada) PHP originally abbreviation for ‘Personal Home Pages’, now ‘PHP Hypertext Processor’ Other key developers: Zeev Surashi and Andi Gutmans (Israel) Open Source PHP version 4.4.3 current at UWE Due to upgrade to PHP 5
  • 3. Scripting languages • A scripting language is: – often evolved not designed – cross-platform since interpreter is easy to port – designed to support a specific task – PHP -> Web support – un-typed variables (but values are typed) – implicit variable declaration – implicit type conversion – stored only as script files – compiled on demand – may run on the server (PHP) or the client (Javascript) • What design and development are involved in using a scripting language like PHP for development in place of a compiled language (Java in JSP, .NET)?
  • 4. PHP details • Procedural language – Compare with Javascript which is event-driven • C-like syntax - { } ; • Extensive Function Library • Good Web-server integration – Script embedded in HTML – Easy access to form data and output of HTML pages • Not 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
  • 5. PHP and HTML • HTML-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”) ?>
  • 6. C-like language • Free 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=6 • Relational 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 • Associative Arrays (hash array in Perl, dictionary in Java) are accessed in the same way: $y[“fred”] • Functions are called with the name followed by arguments in a fixed order enclosed in ( ) : substr(“fred”,0,2) • Case sensitive - $fred is a different variable to $FRED
  • 7. Function library • Basic 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
  • 8. 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” • 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.
  • 9. 3(+1) Tier architecture voice DHTML touch Browser HTTP SQL (IE, FireFox, PHP script Database Opera) Web Server Database vision HTML (Apache, IIS) tables Server Desktop (PC or MAC) SMS Web Service SMS system Client application Remote services
  • 10. Learning PHP • Start with just the basics, installing a script to output an HTML page • Understand how PHP supports interaction with the Browser or other clients • Understand how PHP supports integration with databases – MySQL • Understand how PHP supports integration with other applications – Web services