SlideShare uma empresa Scribd logo
1 de 6
Baixar para ler offline
An overview of PHP

                       Cristian Bogdan




                      What is PHP
• PHP: Hypertext Processor (or Personal Home Page?)
• This lecture goes through the doc: http://www.php.net/manual/en/
• Interpreted language
   – Easy to get something done fast
   – Problems when size and complexity grow
   – Performance penalty (though addressed in later Zend engine)
• A number of PHP organisations and hosting services around the
  net.
• A huge catalogue of features developped by volunteers
• A wide user community definately happy that they not only can
  program, but they also can program for the internet…
• Language in evolution… PHP 5 adds exception handling. OOP is
  also an add-on since PHP4, PHP5 perfects it
   – most OOP concepts and keywords are like in java: class, extends,
     interface, private, protected, etc
   – exceptions are like in Java (try/catch, etc)




                                                                        1
What can PHP do
• CGI scripting of course
  – Based on escapes within HTML pages <?php
    > or <% … %>
• Command line scripting
• GUI applications (PHP-GTK)
  http://gtk.php.net/




                  Installation
• Install the PHP interpreter separately. There is
  good support for this on Linux
• In the webserver configuration, associate the
  php extension with the PHP interpreter
• For serious applications you will need a
  database engine.
• Apache is the typical choice for the web server.
  – Integrated as a module, so no supplementary
    processes are created (in CGI, typically there is one
    process per access, which is very expensive)
• Mysql is the typical db engine




                                                            2
PHP in HTML
• The most often case where PHP is used
• Escaping
   –   <?php …. ?>
   –   <? …. ?>
   –   <script language=”php” > ….</script>
   –   <% .... %>, <%=. … %> like ASP and JSP
• Like in JSP, escaping can be interrupted to write some
  HTML
   <?php
     if ($expression) {
     ?>
   <b>This is true.</b>
   <?php } ?>
• You can see the evolution under community pressure,
  here and in other areas




                            Types
• a variable name begins with $, no type declaration (type
  declaration can be required by passing some settings to
  the interpreter)
• can have one type first, another one later… (BASIC??)
• boolean, integer (similar to C), float (similar to C)
• string
   – single-quoted, no character escapes
   – double-quoted, like C character escapes
   – <<< EOD notation to write longer multiline strings
   – $a.$b appends the string b and at the end of the string a (+ in
     Java)
   – $a(index1, index2) gives a substring
   – string functions in the function library (strlen() like in C)
   – expression intergration ”some text { expression $var } blabla”
• arrays are mappings between keys and values
  (Dictionary/Hashtable/Map in java)
   – $arr = array("foo" => "bar", 12 => true)
• There are automactic type conversions between types
  (very dangerous…). Explicit type conversions exist too




                                                                       3
Other types
• Classes and objects, OOP
• Resources, a kind of reference
• Pseudo-types, a kind of #typedef ?




                    Variables
•   See Types
•   Assignment by value (not by reference)
•   Programming for the lazy
•   Lots of predefined variables, especially related
    to HTTP/CGI
    – _SERVER, _GET, _POST, _COOKIE, _FILES,
      _REQUEST, _SESSION
•   Scope of variables, globals
•   Variable variables ☺
•   External varialbes, useful for forms
•   Functions as variables




                                                       4
Other procedural stuff
• Operators similar to C
• Statements similar to C, plus:
   – <? if(…) : ?> ….<? endif; >
   – foreach () through arrays, just values, or also keys
      • foreach (array_expression as $value) statement
      • foreach (array_expression as $key => $value) statement
• Code inclusion with require() and include()
• Conditional function definition (similar to C #ifdef
  )




                       Features
• HTTP authentication, cookies, file uploads
• Remote files (like
  java.net.URLConnection)
• Connections (like java.net.Socket)
• Persistent db connections
   – Normally db connections are defined with
     engine specific functions as external
     resources. Each access would open its
     connection, that is expensive




                                                                 5
Functions
• Array functions, calendar fuctions, date
  functions, character functions, IO functions,
  printer, file/directory, etc
• Functions for protocols/standards, e.g. FTP,
  HTTP, URL, LDAP, IRC, Mail, NSAPI, popmail,
  XML/XSL, Bzip2/Zip/Zlib
• Functions for various databases (Mysql, Oracle,
  MS SQL server, mSQL, PostgreSQL, SQLite,
  dBase), dbx is general
• Functions for other systems/tools: e.g. Apache,
  COM, Cyrus, PDF, dBase, DBM, DOM, .NET,
  Lotus Notes, GNU readline, Hyperware




                    Conclusions
• Easy to learn from Java or C
• CGI parameters, HTTP sessions, etc are easy to
  recognize
• Good language/system for doing something small fast
  (but then JSP/ASP do most of the same)
• Not a wise choice for a serious/large project due to the
  lack of type safety, lack of OOP in the libraries, etc.
   – Experienced PHP people confirm that larger projects tend to
     become a big mess due to the freedoms that seemed so good in
     the begining, which make programmers lazy
• The array concept is nice, but its name is misleading
  (array means something very different in all the rest of
  Computer Science)
• Still, a very good choice for pragmatists who want to get
  the job done.




                                                                    6

Mais conteúdo relacionado

Semelhante a Php

Semelhante a Php (20)

test
testtest
test
 
IntroductiontoPHP.ppt
IntroductiontoPHP.pptIntroductiontoPHP.ppt
IntroductiontoPHP.ppt
 
ssfsd fsdf ds f
ssfsd fsdf ds fssfsd fsdf ds f
ssfsd fsdf ds f
 
IntroductiontoPHP.ppt
IntroductiontoPHP.pptIntroductiontoPHP.ppt
IntroductiontoPHP.ppt
 
IntroductiontoPHP.ppt
IntroductiontoPHP.pptIntroductiontoPHP.ppt
IntroductiontoPHP.ppt
 
IntroductiontoPHP.ppt
IntroductiontoPHP.pptIntroductiontoPHP.ppt
IntroductiontoPHP.ppt
 
IntroductiontoPHP.ppt
IntroductiontoPHP.pptIntroductiontoPHP.ppt
IntroductiontoPHP.ppt
 
IntroductiontoPHP.ppt
IntroductiontoPHP.pptIntroductiontoPHP.ppt
IntroductiontoPHP.ppt
 
ssfsd fsdf ds f
ssfsd fsdf ds fssfsd fsdf ds f
ssfsd fsdf ds f
 
ssfsd fsdf ds f
ssfsd fsdf ds fssfsd fsdf ds f
ssfsd fsdf ds f
 
IntroductiontoPHP.ppt
IntroductiontoPHP.pptIntroductiontoPHP.ppt
IntroductiontoPHP.ppt
 
ssfsd fsdf ds f
ssfsd fsdf ds fssfsd fsdf ds f
ssfsd fsdf ds f
 
ssfsd fsdf ds f
ssfsd fsdf ds fssfsd fsdf ds f
ssfsd fsdf ds f
 
IntroductiontoPHP.ppt
IntroductiontoPHP.pptIntroductiontoPHP.ppt
IntroductiontoPHP.ppt
 
hgfgf
hgfgfhgfgf
hgfgf
 
IntroductiontoPHP.ppt
IntroductiontoPHP.pptIntroductiontoPHP.ppt
IntroductiontoPHP.ppt
 
test
testtest
test
 
sdfsdfsdf
sdfsdfsdfsdfsdfsdf
sdfsdfsdf
 
345345
345345345345
345345
 
test
testtest
test
 

Último

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Último (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Php

  • 1. An overview of PHP Cristian Bogdan What is PHP • PHP: Hypertext Processor (or Personal Home Page?) • This lecture goes through the doc: http://www.php.net/manual/en/ • Interpreted language – Easy to get something done fast – Problems when size and complexity grow – Performance penalty (though addressed in later Zend engine) • A number of PHP organisations and hosting services around the net. • A huge catalogue of features developped by volunteers • A wide user community definately happy that they not only can program, but they also can program for the internet… • Language in evolution… PHP 5 adds exception handling. OOP is also an add-on since PHP4, PHP5 perfects it – most OOP concepts and keywords are like in java: class, extends, interface, private, protected, etc – exceptions are like in Java (try/catch, etc) 1
  • 2. What can PHP do • CGI scripting of course – Based on escapes within HTML pages <?php > or <% … %> • Command line scripting • GUI applications (PHP-GTK) http://gtk.php.net/ Installation • Install the PHP interpreter separately. There is good support for this on Linux • In the webserver configuration, associate the php extension with the PHP interpreter • For serious applications you will need a database engine. • Apache is the typical choice for the web server. – Integrated as a module, so no supplementary processes are created (in CGI, typically there is one process per access, which is very expensive) • Mysql is the typical db engine 2
  • 3. PHP in HTML • The most often case where PHP is used • Escaping – <?php …. ?> – <? …. ?> – <script language=”php” > ….</script> – <% .... %>, <%=. … %> like ASP and JSP • Like in JSP, escaping can be interrupted to write some HTML <?php if ($expression) { ?> <b>This is true.</b> <?php } ?> • You can see the evolution under community pressure, here and in other areas Types • a variable name begins with $, no type declaration (type declaration can be required by passing some settings to the interpreter) • can have one type first, another one later… (BASIC??) • boolean, integer (similar to C), float (similar to C) • string – single-quoted, no character escapes – double-quoted, like C character escapes – <<< EOD notation to write longer multiline strings – $a.$b appends the string b and at the end of the string a (+ in Java) – $a(index1, index2) gives a substring – string functions in the function library (strlen() like in C) – expression intergration ”some text { expression $var } blabla” • arrays are mappings between keys and values (Dictionary/Hashtable/Map in java) – $arr = array("foo" => "bar", 12 => true) • There are automactic type conversions between types (very dangerous…). Explicit type conversions exist too 3
  • 4. Other types • Classes and objects, OOP • Resources, a kind of reference • Pseudo-types, a kind of #typedef ? Variables • See Types • Assignment by value (not by reference) • Programming for the lazy • Lots of predefined variables, especially related to HTTP/CGI – _SERVER, _GET, _POST, _COOKIE, _FILES, _REQUEST, _SESSION • Scope of variables, globals • Variable variables ☺ • External varialbes, useful for forms • Functions as variables 4
  • 5. Other procedural stuff • Operators similar to C • Statements similar to C, plus: – <? if(…) : ?> ….<? endif; > – foreach () through arrays, just values, or also keys • foreach (array_expression as $value) statement • foreach (array_expression as $key => $value) statement • Code inclusion with require() and include() • Conditional function definition (similar to C #ifdef ) Features • HTTP authentication, cookies, file uploads • Remote files (like java.net.URLConnection) • Connections (like java.net.Socket) • Persistent db connections – Normally db connections are defined with engine specific functions as external resources. Each access would open its connection, that is expensive 5
  • 6. Functions • Array functions, calendar fuctions, date functions, character functions, IO functions, printer, file/directory, etc • Functions for protocols/standards, e.g. FTP, HTTP, URL, LDAP, IRC, Mail, NSAPI, popmail, XML/XSL, Bzip2/Zip/Zlib • Functions for various databases (Mysql, Oracle, MS SQL server, mSQL, PostgreSQL, SQLite, dBase), dbx is general • Functions for other systems/tools: e.g. Apache, COM, Cyrus, PDF, dBase, DBM, DOM, .NET, Lotus Notes, GNU readline, Hyperware Conclusions • Easy to learn from Java or C • CGI parameters, HTTP sessions, etc are easy to recognize • Good language/system for doing something small fast (but then JSP/ASP do most of the same) • Not a wise choice for a serious/large project due to the lack of type safety, lack of OOP in the libraries, etc. – Experienced PHP people confirm that larger projects tend to become a big mess due to the freedoms that seemed so good in the begining, which make programmers lazy • The array concept is nice, but its name is misleading (array means something very different in all the rest of Computer Science) • Still, a very good choice for pragmatists who want to get the job done. 6