Sunteți pe pagina 1din 22

What is ...?

What is server/client? What is HTTP request/response? What is web server? What is IE/Mozilla? What is Apache? PHP Summary PHP language

Why?

Why am I being told all those on the previous slide. I came here for PHP. Please wait... You will soon get to know. I will talk of lot of stuff which may be difficult to get to know the first time. You will need to do get some hands-on-experience. Please attend the workshop. Details after lecture.

What is server/client?

Server: It is that system which serves some kind of requests. Requests follow a syntax the protocol. Connections are established with sockets. Client: It is that system which sends the required requests to the server. Now what is protocol? What is socket?

What is server/client?

Protocol: This is a set of commands which the server and client agree to work on so that the server can understand the request generated by the client. It is like a set of rules. Socket: Can be thought of as a pipeline on which the protocol messages are sent from one machine to another. Sockets are established on different ports. Types of sockets: TCP, UDP, Raw etc.

What is HTTP request?

HTTP: HyperText Transfer Protocol. It is the protocol on which the Internet works (mostly) and the data transfer between clients and servers takes place. HTTP format (for both request and response):
Request/Response headers <blank line> Request/Response body

HTTP request: The request generated by HTTP clients that adhere to HTTP protocol to get the data from server.

What is HTTP request?


At dos/unix prompt, do the following: $ telnet 202.141.80.34 80 Trying 202.141.80.34... Connected to umtru.iitg.ernet.in (202.141.80.34). Escape character is '^]'. GET /~k.kishore/ HTTP/1.1\n\n
NOTE: telnet is a very simple client which can connect to any server on any port. (Very good start point to hack some old vulnerable machines.)

What is HTTP response?

HTTP response: The output generated by the server on to the socket that adheres to HTTP protocol giving the required data to the client (through the socket)

What is HTTP response?

The response to the previous request:


HTTP/1.1 200 OK Date: Thu, 02 Nov 2006 08:41:10 GMT Server: Apache/2.0.46 (Red Hat) Accept-Ranges: bytes Content-Length: 4078 Connection: close Content-Type: text/html; charset=UTF-8 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test Page for the Apache HTTP Server on Red Hat Enterprise Linux</title> ... </html> Connection closed by foreign host.

What is web server?

It is a not so simple server which can understand (only) HTTP protocol and give corresponding HTTP response to a HTTP request. Examples: Apache, IIS etc.

What is IE/Mozilla?

These are not so simple HTTP clients that have many features.
(Interpretation of javascript, CSS, HTML -> GUI, HTTPS are features these clients have built-in in them. But in our context they are just clients that connect to a server.)

Building a simple HTTP client is very easy. May be we will implement one in following CSEA workshops.

What is Apache?

Apache is the most widely used open-source web server through out the world. All the CSE department servers have Apache installed. The Apache servers 202.141.80.5, 202.141.80.6 have Apache installed on them which serve the requests addressed to http://www.iitg.ernet.in by outside world. Installation of Apache What is 127.0.0.1?

You have the base now...

Why is he talking about server, client, HTTP, request, response? I came here to learn PHP. Life time of a session. What happens from the time you login till you logout (in orkut may be)? Difference between static and dynamic pages.

You have the base now...

Servers have many clients connected at a time. Static pages do not know about who is browsing. They generate same HTTP response for all HTTP requests. They cannot distinguish between different HTTP requests. Dynamic pages know about who generated the HTTP request. Hence they give different HTTP response for different HTTP request.

PHP

PHP is the most widely used open-source server side scripting language. Why is it called server-side? PHP is a language which can GENERATE HTTP responses (for that matter even images, PDFs) on the fly based on HTTP requests. You log-in, and you see your scraps and he logs-in and he sees his scraps. Examples: PHP, Perl, ASP, ASP.NET etc

PHP

It is called server-side because the script written is processed on the server and then HTML is generated. THE SCRIPT IS PARSED ON THE SERVER. Then is there a client side scripting language? How is it different from server-side counterpart? Javascript is an example of client side scripting language. IT IS PARSED ON THE CLIENT.

PHP

Javascript is as such sent to the client and the client understands it and does the required action. Lets see all this with examples -

PHP

Installation of PHP Examples: 1. HTTP request, HTTP response 2. Form request to a static page 3. My first PHP page, form request to a dynamic page. 4. Javascript example. 5. What is file:// and http://

Lets summarise...

You will need to understand what is a HTTP header, request, response. (You don't need to know about telnet, server, client) You will need to know perfect distinction on which code is parsed on server and which on client. Any doubts please get them clarified now...

Lets summarise...

Finally, PHP gives you all the interface to know who is browsing on the client side by giving you appropriate variables and functions. Now, Let's start PHP...
(PHP is very very similar to C with semi-OOPS support)

PHP

All the PHP code is enclosed in between '<?php' and '?>'. There is a PHP parser that is invoked every time a PHP page is requested in a HTTP request. That parser understands the HTTP request, gives the necessary input to the PHP page and then starts parsing the PHP page to generate the required HTML.

PHP

PHP Syntax (echo, comments) PHP Variables ($,.) PHP Operators (+,-,/,*,% ==,<,>,>=,<=,!= &&,||,!) PHP If...Else PHP Switch PHP Arrays PHP Looping PHP Forms PHP $_GET, $_POST

Resources

Basic tutorial: http://www.w3schools.com/php/default.asp Configuring Apache for PHP: http://blogcms.com/?item=install-apachemysql-and-php-on-windows (it is now possible to PHP: www.php.net, Apache: www.apache.org Download PHP manual from above site for more help on PHP

load PHP as a module in Apache in Windows platform also)

S-ar putea să vă placă și