⊗ppPmHpRH 397 of 447 menu

HTTP Request Headers in PHP

In PHP, you can get the values of request headers. They are contained in the $_SERVER superglobal array. The key for each request header starts with 'HTTP_', followed by the name of that header in uppercase letters.

Let's, for example, get the contents of the Host header:

<?php echo $_SERVER['HTTP_HOST']; ?>

If the header name contains hyphens, they are converted to underscores in the key in PHP. As an example, let's get the contents of the header Accept-Encoding:

<?php echo $_SERVER['HTTP_ACCEPT_ENCODING']; ?>

Get the value of the Accept header.

Get the value of the Accept-Language header.

Output the contents of the $_SERVER variable using var_dump. Visually, "by eye", determine which values are headers and which are something else.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline