HTML/XHTML and HTTP Basics Review PHP and the Web Server Architecture Model Overview of PHP Capabilities CGI vs. Shared Object Model
- 1. PHP Module 1 Hussain Fakhruddin [email_address]
2. Agenda
- HTML/XHTML and HTTP Basics Review
- PHP and the Web Server Architecture Model
- Overview of PHP Capabilities
- CGI vs. Shared Object Model
3. HTML/XHTML and HTTP Basics Review
- HTML/XHTML a language that every browser knows.
- HTTP a protocol that every machine uses to talk with
others.
4. HTML Hyper Text Markup Language
- Basically designed and used as a common language to retrieve
documents from web.
- More features (called as tags) added later.
- Now is replaced by dynamic languages (like PHP) in some
places.
- Tags are basically used to organize contents of document.
5. XHTML eXtended HTML
- Each starting tag must have ending tag.
- There are strict rules to be followed.
- e.g. In HTML
is allowed, but in XHTML it must be
Similarly: HTML XHTML
- ...
- ......
6. Web Server Architecture Model
- Like a query session after a lecture!
- Clients send request, server sends reply to the requested.
- Our web browser is typical client, which formats HTTP (or HTTPS
etc.) request and sends to a server.
- A server (e.g. Apache onwww.sachinism.com ) formats response
and sends back to the browser.
7. Working of Internet 8. A representation of client-server talk
- 1 Client Server To Server, Can you please give me index.htm? 9. A
representation of client-server talk - 2 Client Server To Client,
Sure, here it is... Contents of index.htm 10. 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
11. HTTP HyperText Transfer Protocol
- Protocol for talks between Client and server for Websites.
- Simple, text based protocol
- Two most frequently used methods (operations) GET and POST
12. HTTP Format
-
- Request line (e.g. GET /images/logo.gif HTTP/1.1)
-
- Headers (e.g. Accept-Language: en)
13. HTTP Request in details
- Request method e.g. GET / POST / PUT
- URL where to send the request
- POST /my_dir/my_sub_dir/my_file.htm HTTP/1.1
14. Request methods -1
- HEAD Request only headers for an GET request, not actual
resource / data. Used to retrieve meta-data.
- GET Request actual resource. Used as a method to send data
along with request. This data is shown on address bar of a
browser!
- 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.
15. Request methods -2
- DELETE Removes / Delets a specified resource.
- TRACE Redisplays a request, to check if some server in midway
to the destination has changed any value.
- OPTIONS Returns methods supported by the server's specific
resource. Used to check server's functionality / support.
- CONNECT Converts the request connection to a transparent TCP/IP
tunnel. Not much secure.
16. HTTP Format
17. HTTP Response Status Line
18. HTTP Response Status details
- 200 OK Request successful
- 302 Moved Permanently URL is no longer used by server
- 404 Page not found Requested document / resource not found
- 500 Internal server error Some error on server
19. Request / Response Headers
- Exchange of information between client and server.
- Each line : Header name + value
- Classification of header lines:
20. General Header
- Can be present in both request and response.
-
- Cache-control Information about caching
-
- Connection Connection should be either closed or keptopen.
21. Request Header
- Specific to request messages.
-
- Accept Message format that is supported byclient
-
- Accept-language Language that client accept
-
- Host Host and port number of client
-
- If-modified-since Send the document if newer thanspecified
date
-
- If-unmodified-since Send the document if older thanspecified
date
22. Response Header
- Specific to response message
-
- Retry-after Date after which server is available
23. Entity Header
- Mostly used in response message
-
- Content-encoding Encoding scheme
-
- Content-language Language
-
- Last-modified Last modification date and time
-
- Content-type Type of media document
24. HTTP Example
- Request GET http://www.sachinism.com/index.htm HTTP/1.0 Accept:
text/html Accept: image/jpeg
- Response HTTP/1.0 200 OK Date: Thu, 20-Feb-08 09.00.00 GMT
Server: Challenger MIME-version: 1.0 Content-length: 2048 >
25. A representation of client-server talk - 1
-
- Request GET http://www.sachinism.com/index.htm HTTP/1.0 Accept:
text/html Accept: image/jpeg
Client Server To Server, Can you please give me index.htm? 26. A
representation of client-server talk - 2
-
- Response HTTP/1.0 200 OK Date: Thu, 20-Feb-08 09.00.00 GMT
Server: Challenger MIME-version: 1.0 Content-length: 2048
Client Server To Client, Sure, here it is... Contents of
index.htm 27. 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 28. CGI - The Common
Gateway Interface
- CGI is a standard protocol for interfacing external application
software with an information server, commonly a web server.
- an information server responds to requests(in the case of web
servers, requests from client web browsers)
- Each time a request is received, the server analyzes what the
request asks for, and returns the appropriate output.
29. 30. CGI
- The two simplest ways, for the server, of doing this are the
following:
- 1) If the request identifies a file stored on disk, return the
contents of that file;
- 2) If the request identifies an executable command and possibly
arguments, run the command and return its output
31. 32. PHP
- PHP Hyper Processor or Personal Hypertext Processor
- A server side programming language
- Emerged as leading language in server side application
development since a decade!
- 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
33. Why use PHP?
- 1)PHP is a server-side interpreter which is Open Source and
free;
- 2)So is a growing number of PHP web applications;
- 3)PHP provides familiar syntax to C, Perl and Java
developers;
- 4)PHP has fast connections to popular databases;
- 5)PHP has fast native connections to the Open Source MySQL
database;
34. Why use PHP?
- 6)PHP runs reliably on Windows, Linux and Mac servers and
clients;
- 7)PHP web pages run reliably on all the popular browsers;
- 8)PHP's associative arrays are very useful for UI and database
apps;
- 9)PHP's object oriented classes are easy to understand;
- 10)PHP has been very promiscuous-linking to PDF, SWF, XML,
Java, etc, etc.
35. Role of PHP - advantage
- Everything goes personalize I.E. User settings, look and feel,
some private data etc.
- Provides user interactivity
- Allows to create own web applications that can be executed
remotely!
- Examples : any website provides login and thereafter services,
live cricket scores on sachinism.com
36. HTML/JSVS PHP
- JavaScript = ClientSide; PHP = ServerSide
- With php you can have the remote time, with js you can have
user time...
- with php the source is not lookable in the source code with js
the source can be see in the source code of the page.
- Javascript NOT EQUAL TO PHP
37. Recap 38. Summary
- Internet era began with static webpages written in HTML, which
required strict rules created XHTML.
- Every web based application (essentially webpages / websites)
are communicating on HTTP which follow specific format.
- User requests something to server and server sends back
relevant data implements client server architecture.
- Later on, server side programming languages like PHP adds user
interactivity, personalisation of websites.
39. Whats next?
-
- Obtaining, Installing and Configuring PHP
-
- Obtaining PHP Source Code
-
- Installing PHP from Binary Packages
-
- Dynamic Extensions, Checking Install withphpinfo()
Function.