PHP HTTP & HTTPS
If you followed this tutorial from the beginning, you must have a basic idea on the "client-server model". Now, we are going to explain it thoroughly.
What is HTTP?
- HTTP stands for Hypertext Transfer Protocol
- HTTP is a protocol (a set of rules) which defines how the data should be transfered
- HTTP is the main data communication method of the web
How does HTTP work?
- HTTP can establish a connection between a client and a server.
- The client can be any program or device. Most often, browsers and terminal programs are used. The client sends an HTTP Request to the server.
- The server can be any program which is capable of handling HTTP requests. Most often they are cloud computers which are accessible via internet. The server processes the HTTP Request and returns an HTTP Response back to the client.
The simple process is:
- The client sends an HTTP request (According to HTTP rules)
- The server receives the HTTP request
- The server process the HTTP request (ex: Execute a PHP script)
- The server sends an HTTP response back to the client (According to HTTP rules)
- The client receives the response
- The client acts according to the response (ex: Render the webpage)
What Can HTTP Do?
HTTP can allow clients to access HTTP Resources that are identified by URLs (Uniform Resource Locators).
As a PHP developer, you can use HTTP to allow users to access your PHP files (That's what we did from the beginning). Let's take the example we had in the Hello World chapter. Our PHP file was
hello.php and contained the following simple PHP code.
<?php echo 'Hello World';