Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Starting With Php

Related Books

Free with a 30 day trial from Scribd

See all
  • Be the first to comment

  • Be the first to like this

Starting With Php

  1. 1. PHP – Starting with PHP Harit Kothari [email_address]
  2. 2. Agenda <ul><li>HTML/XHTML and HTTP Basics Review </li></ul><ul><li>PHP and the Web Server Architecture Model </li></ul><ul><li>Overview of PHP Capabilities </li></ul>
  3. 3. HTML/XHTML and HTTP Basics Review <ul><li>HTML/XHTML – a language that every browser knows. </li></ul><ul><li>HTTP – a protocol that every machine uses to talk with others. </li></ul>
  4. 4. HTML – Hyper Text Markup Language <ul><li>Basically designed and used as a common language to retrieve documents from web. </li></ul><ul><li>More features (called as tags) added later. </li></ul><ul><li>Now is replaced by dynamic languages (like PHP) in some places. </li></ul><ul><li>Tags are basically used to organise contents of document. </li></ul>
  5. 5. XHTML – eXtended HTML <ul><li>A strict format of HTML </li></ul><ul><li>Each starting tag must have ending tag. </li></ul><ul><li>There are strict rules to be followed. </li></ul><ul><li>e.g. In HTML <br> is allowed, but in XHTML it must be <BR/> Similarly: HTML XHTML <p> <P/> <li>... <LI>......</LI> </li></ul>
  6. 6. HTTP – HyperText Transfer Protocol <ul><li>Port no. 80 </li></ul><ul><li>Simple, text based protocol </li></ul><ul><li>Stateless </li></ul><ul><li>Two most frequently used methods (operations) – GET and POST </li></ul>
  7. 7. HTTP Format <ul><li>Request form </li></ul><ul><ul><li>Request line (e.g. GET /images/logo.gif HTTP/1.1) </li></ul></ul><ul><ul><li>Headers (e.g. Accept-Language: en) </li></ul></ul><ul><ul><li>An optional message body </li></ul></ul>
  8. 8. HTTP Request in details <ul><li>Request method – e.g. GET / POST / PUT </li></ul><ul><li>URL – where to send the request </li></ul><ul><li>HTTP version – e.g. 1.1 </li></ul><ul><li>POST /my_dir/my_sub_dir/my_file.htm HTTP/1.1 </li></ul>
  9. 9. Request methods -1 <ul><li>HEAD Request only headers for an GET request, not actual resource / data. Used to retrieve meta-data. </li></ul><ul><li>GET Request actual resource. Used as a method to send data along with request. This data is shown on address bar of a browser! </li></ul><ul><li>POST Request actual resource. Most common method used to send data to be processed by the resource. This data is not shown in address bar, is inserted in request body. </li></ul>
  10. 10. Request methods -2 <ul><li>PUT Uploads a resource. </li></ul><ul><li>DELETE Removes / Delets a specified resource. </li></ul><ul><li>TRACE Redisplays a request, to check if some server in midway to the destination has changed any value. </li></ul><ul><li>OPTIONS Returns methods supported by the server's specific resource. Used to check server's functionality / support. </li></ul><ul><li>CONNECT Converts the request connection to a transparent TCP/IP tunnel. Not much secure. </li></ul>
  11. 11. HTTP Format <ul><li>Response form </li></ul><ul><ul><li>Status line </li></ul></ul><ul><ul><li>Headers </li></ul></ul><ul><ul><li>An optional message body </li></ul></ul>
  12. 12. HTTP Response Status Line <ul><li>HTTP Version </li></ul><ul><li>Status code of 3 digits </li></ul><ul><li>Status description </li></ul>
  13. 13. HTTP Response – Status details <ul><li>200 OK Request successful </li></ul><ul><li>302 Moved Permanently URL is no longer used by server </li></ul><ul><li>404 Page not found Requested document / resource not found </li></ul><ul><li>500 Internal server error Some error on server </li></ul>
  14. 14. Request / Response Headers <ul><li>Exchange of information between client and server. </li></ul><ul><li>Each lie : Header name + value </li></ul><ul><li>Classification of header lines: </li></ul><ul><ul><li>General header </li></ul></ul><ul><ul><li>Request header </li></ul></ul><ul><ul><li>Response header </li></ul></ul><ul><ul><li>Entity header </li></ul></ul>
  15. 15. General Header <ul><li>Can be present in both – request and response. </li></ul><ul><li>Header Description </li></ul><ul><ul><li>Cache-control Information about caching </li></ul></ul><ul><ul><li>Connection Connection should be either closed or kept open. </li></ul></ul><ul><ul><li>Date Current date </li></ul></ul>
  16. 16. Request Header <ul><li>Specific to request messages. </li></ul><ul><li>Header Description </li></ul><ul><ul><li>Accept Message format that is supported by client </li></ul></ul><ul><ul><li>Accept-language Language that client accept </li></ul></ul><ul><ul><li>Host Host and port number of client </li></ul></ul><ul><ul><li>If-modified-since Send the document if newer than specified date </li></ul></ul><ul><ul><li>If-unmodified-since Send the document if older than specified date </li></ul></ul>
  17. 17. Response Header <ul><li>Specific to response message </li></ul><ul><li>Header Description </li></ul><ul><ul><li>Age Age of document </li></ul></ul><ul><ul><li>Retry-after Date after which server is available </li></ul></ul><ul><ul><li>Sever Sever name + port </li></ul></ul>
  18. 18. Entity Header <ul><li>Mostly used in response message </li></ul><ul><li>Header Description </li></ul><ul><ul><li>Content-encoding Encoding scheme </li></ul></ul><ul><ul><li>Content-language Language </li></ul></ul><ul><ul><li>Content-length Length </li></ul></ul><ul><ul><li>Last-modified Last modification date and time </li></ul></ul><ul><ul><li>Content-type Type of media document </li></ul></ul>
  19. 19. HTTP Example <ul><li>Request GET http://www.sachinism.com/index.htm HTTP/1.0 Accept: text/html Accept: image/jpeg </li></ul><ul><li>Response HTTP/1.0 200 OK Date: Thu, 20-Feb-08 09.00.00 GMT Server: Challenger MIME-version: 1.0 Content-length: 2048 << HTML Body >> </li></ul>
  20. 20. PHP <ul><li>PHP Hyper Processor or Personal Hypertext Processor </li></ul><ul><li>A server side programming language </li></ul><ul><li>Emerged as leading language in server side application development since a decade! </li></ul><ul><li>HTML can simply display data (static) whereas PHP can be executed on server and the result is displayed on client (Dynamic) - will discuss later in this session </li></ul>
  21. 21. Web Server Architecture Model <ul><li>Client server model. </li></ul><ul><li>Like a query session after a lecture! </li></ul><ul><li>Clients send request, server sends reply to the requested. </li></ul><ul><li>Our web browser is typical client, which formats HTTP (or HTTPS etc.) request and sends to a server. </li></ul><ul><li>A server (e.g. Apache on www.sachinism.com ) formats response and sends back to the browser. </li></ul>
  22. 22. A representation of client-server talk - 1 <ul><ul><li>Request GET http://www.sachinism.com/index.htm HTTP/1.0 Accept: text/html Accept: image/jpeg </li></ul></ul>Client Server To Server, “Can you please give me index.htm?”
  23. 23. A representation of client-server talk - 2 <ul><ul><li>Response HTTP/1.0 200 OK Date: Thu, 20-Feb-08 09.00.00 GMT Server: Challenger MIME-version: 1.0 Content-length: 2048 <<HTML Body >> </li></ul></ul>Client Server To Client, “ Sure, here it is...” Contents of index.htm
  24. 24. A representation of client-server talk - 3 Client Server Wow... I am lucky to get index.htm so fast! Actual webpage, that can be displayed on browser
  25. 25. Role of PHP - advantage <ul><li>Everything goes personalise. i.e. User settings, look and feel, some private data etc. </li></ul><ul><li>Provides user interactivity </li></ul><ul><li>Allows to create own web applications that can be executed remotely! </li></ul><ul><li>Examples : any website provides login and thereafter services, live cricket scores on sachinism.com </li></ul>
  26. 26. Summary <ul><li>Internet era began with static webpages written in HTML, which required strict rules – created XHTML. </li></ul><ul><li>Every web based application (essentially webpages / websites) are communicating on HTTP which follow specific format. </li></ul><ul><li>User requests something to server and server sends back relevant data – implements client server architecture. </li></ul><ul><li>Later on, server side programming languages like PHP adds user interactivity, personalisation of websites. </li></ul>
  27. 27. Whats next? <ul><li>Starting up with practical PHP </li></ul><ul><ul><li>Obtaining, Installing and Configuring PHP </li></ul></ul><ul><ul><li>Obtaining PHP Source Code </li></ul></ul><ul><ul><li>Installing PHP from Binary Packages </li></ul></ul><ul><ul><li>Dynamic Extensions, Checking Install with phpinfo() Function. </li></ul></ul>

×