HTTP_HOST: It is fetched from HTTP request header obtained from the client request
Website: http://www.geeksforgeeks.org HTTP_HOST: www.geeksforgeeks.org
HTTP_SERVER: It is fetched from the server name based on the host configuration.
Website: http://www.geeksforgeeks.org HTTP_SERVER: Display the server name
|It retrieve the request header from the client.||It retrieve the server configuration.|
|It is not reliable since its value can be modified.||It is more reliable as its value comes from sever configuration.|
|Syntax: $_SERVER[‘HTTP_HOST’]||Syntax: $_SERVER[‘SERVER_NAME’]|
|It gives the domain name of the host where the request is fulfilled.||It gives the server name specified in host configuration.|
|Example: localhost:8080||Example: www.google.com|
|It is based on request from client.||It is based on configuration of web server.|
|As it is directly related to request so it is used in most of the applications.||It does not give any information about the request at all.|
|It is taken from the target host.||It is taken from server configuration.|
|It is client controlled value.||It is server controlled value|
Example of HTTP_HOST:
It display the host name.
Example of HTTP_SERVER:
It display the server name.
Note: In case of localhost, HOST and SERVER name both will same.
- Difference and Similarities between PHP and C
- Difference between try-catch and if-else statements in PHP
- Difference between isset() and array_key_exists() Function in PHP
- What is the difference between the | and || or operator in php?
- What is the difference between public, private, and protected in PHP?
- Difference between require-dev and require in PHP?
- What is the difference between is_a() function and instanceof in PHP?
- What is the difference between echo, print, and print_r in PHP?
- What is the difference between array_merge and array + array in PHP?
- What is the difference between a language construct and a “built-in” function in PHP ?
- Difference between “!==” and “==!” in PHP
- Difference between array() and  in PHP
- What is the difference between single-quoted and double-quoted strings in PHP?
- Difference between break and continue in PHP
- What is the difference between Perl and PHP ?
- Difference Between JSP and PHP
- What is the difference between fopen modes “r+”, "rw+" and “w+” in PHP?
- Difference Between “php artisan dump-autoload” and “composer dump-autoload”
- Difference between file_get_contents and cURL in PHP
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.