
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
How can I get PHP to display the headers it received from a browser?
The below line of code can be used to display the header that the PHP code received via a browser −
<?php print_r($_SERVER[URL]) ?>
or
Example
$headers = getallheaders(); foreach($headers as $key=>$val){ echo $key . ': ' . $val . '<br>'; }
Output
This will produce the following output −
Host: www.websitename.com Content-Length: 180 Cache-Control: max-age=0 Origin: http://www.websitename.com Upgrade-Insecure-Requests: 1 Content-Type: application/x-www-form-urlencoded User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 Referer: http://www.writephponline.com/ Accept-Encoding: gzip, deflate Accept-Language: en-GB,en-US;q=0.9,en;q=0.8 Cookie: _ga=GA1.2.118418268.1575911248; _gid=GA1.2.1794052867.1576852059
- Related Articles
- How to disable browser print options (headers, footers, margins) from the page with CSS?
- How to get the list of column headers from a Pandas DataFrame?
- How can I make a browser to browser (peer to peer) connection in HTML?
- How can I get elements from a Java List?
- How can I get enum possible values in a MySQL database using PHP?
- How to get id from tr tag and display it in a new td with JavaScript?
- How can I display Toast messages from a thread in Android using Kotlin?
- How do I get email-id from a MongoDB document and display with print()
- How to get page source as it is in browser using selenium?
- How can I display only unique record from MongoDB and ignore the duplicates?
- How to correctly get a value from a JSON PHP?
- How can we display all the records from MySQL table with the help of PHP script?
- How can I get the output of multiple MySQL tables from a single query?
- PHP: How do I display the contents of a textfile on my page?
- How to get file name from a path in PHP?

Advertisements