PHP TUTORIALPHP TutorialPHP InstallationPHP Hello WorldPHP Basic SyntaxPHP CommentsPHP VariablesPHP Variable ScopePHP ConstantsPHP StringsPHP OutputPHP Data TypesPHP Type CastingPHP OperatorsPHP ConditionalsPHP Shorthand ConditionalsPHP LoopsPHP Loop Control StructuresPHP FunctionsPHP String FunctionsPHP ArraysPHP Superglobal VariablesPHP in HTMLPHP AdvancedPHP Include and RequirePHP HTTP & HTTPSPHP RegexRegex IntroductionRegex PCRE SyntaxPHP PREG FunctionsPHP FormsPHP Forms IntroductionPHP Forms CreatingPHP Forms SecurityPHP Forms ValidationPHP Forms Required InputsPHP Forms StickyPHP Forms Advanced ValidationPHP Forms FinishingPHP OOPPHP OOP IntroductionPHP OOP ClassesPHP OOP PropertiesPHP OOP ObjectsPHP OOP MethodsPHP OOP $this KeywordPHP OOP Constructors and DestructorsPHP OOP VisibilityPHP OOP InheritancePHP OOP Abstract Classes and MethodsPHP OOP InterfacesPHP OOP TraitsPHP OOP ConstantsPHP OOP StaticPHP OOP NamespacesPHP OOP Autoloading


In this chapter, we will be learning how the Hypertext Transfer Protocol (HTTP) work. In the beginning, there is some theory on HTTP, which is very important for any web developer. Then, HTTPS is explained. Finally, the usage of PHP with HTTP and HTTPS is explained.

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.
HTTP Communication
HTTP Communication

The simple process is:

  1. The client sends an HTTP request (According to HTTP rules)
  2. The server receives the HTTP request
  3. The server process the HTTP request (ex: Execute a PHP script)
  4. The server sends an HTTP response back to the client (According to HTTP rules)
  5. The client receives the response
  6. 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.

echo 'Hello World'; 

Visit PHP Help group to get some help from experts.
Profile Picture
Supun Kavinda
I'm the Founder of Hyvor, Web Developer, Physics Lover, Flutist, and a Table Tennis Player.
My Websites