Change language

How to read any request header in PHP

HTTP request header:when you enter a URL in the browser address bar and try to access it, the browser sends an HTTP request to the server. The HTTP request header contains information in the form of a text entry, which includes a lot of useful information, such as the type, capabilities and version of the browser that generates the request, the operating system used by the client, the page requested, the various types of outputs accepted by the browser, and so on. Further. Upon receiving the request header, the web server will send an HTTP response header to the client.Read any request header:this can be done using the getallheaders() function.Example 1: foreach ( getallheaders () as $name = > $value ) { echo "$name: $value
"
; }
?>
Output:
Host: 127.0.0.3:2025 Connection: keep-alive Cache-Control: max-age = 0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla / 5.0 (X11; Linux x86_64) AppleWebKit / 537.36 (KHTML , like Gecko) Chrome / 70.0.3538.67 Safari / 537.36 Accept: text / html, application / xhtml + xml, application / xml; q = 0.9, image / webp, image / apng, * / *; q = 0.8 Accept-Encoding : gzip, deflate, br Accept-Language: en-US, en; q = 0.9 
Example 2:This can be achieved using the apache_request_headers() function. $header = apache_request_headers(); foreach ( $header as $headers = > $value ) { echo "$headers: $value
"
; }
?>
Host: 127.0.0.6:2027 Connection: keep-alive Cache-Control: max-age = 0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla / 5.0 (X11; Linux x86_64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 70.0.3538.67 Safari / 537.36 Accept: text / html, application / xhtml + xml, application / xml; q = 0.9, image / webp, image / apng, * / *; q = 0.8 Accept-Encoding: gzip, deflate, br Accept-Language: en-US, en; q = 0.9 
Link: http://php.net/manual /en/function.header.php

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

12 answers

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

12 answers

NUMPYNUMPY

glob exclude pattern

12 answers

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

12 answers

NUMPYNUMPY

Python CSV error: line contains NULL byte

12 answers

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

12 answers


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

sin

How to specify multiple return types using type-hints

exp

Printing words vertically in Python

exp

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

cos

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically