PHP Introduction Chapter 1
PHP Introduction Chapter 1
Ch03
Web Modules
1
Web Server
• A Web Server is a software application which handles HTTP
requests sent by the HTTP client, like web browsers, and
returns web pages in response to the clients. Web servers
usually deliver html documents along with images, style
sheets, and scripts.
• The HTTP 200 OK success status response code indicates that the request
has succeeded
• Not found 404 The server has not found anything matching the URI given
• 301: A server returns a 301 HTTP response when the requested URL has
moved permanently to a new URL. If a user tries to visit the old URL, it
will return a 301 HTTP status, pointing the browser to the new URL. If you
move a page without adding a 301 redirect, users trying to visit the old
URL will see a 404 error. Plus, using a 301 HTTP status will pass full link
• The HEAD method asks for a response identical to a GET request, but without
the response body.
• POST
• The HTTP POST method sends data to the server. The type of the body of the
request is indicated by the Content-Type header.
Request Object Properties
Following is the list of few properties associated with request object.
Display Text from Browser:
• const http = require('http');
•
const server = http.createServer((req , res)=>{
• console.log(req.url , req.method);
•
res.setHeader('Content-type' , 'Text/plain');
• res.write('welcome my website');
• res.end();
• });