Jump to content

Get headers from ob_get_contents


Dareros

Recommended Posts

Hi;

I want to get the response headers using ob_get_contents ?

 

For example using file_get_contents, it is easy by accessing the variable $http_response_header like that :

<?php
$content = file_get_contents($url);
print_r($http_response_header);
?>

But how to do that using ob_get_contents without a file_get_contents ? something like for example :

<?php
ob_start();
include($path_to_script_here);
$string = ob_get_contents();
// Access the headers here
ob_end_clean();
?>

Thank you

Link to comment
https://forums.phpfreaks.com/topic/291498-get-headers-from-ob_get_contents/
Share on other sites

Hi, but how to get the status code and other headers information ?

This is the header i get, still doesn't contain all the info why ?

0 : X-Content-Type-Options: nosniff
1 : Server: Apache
2 : X-Powered-By:
3 : P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
4 : Content-Type: text/html; charset=utf-8
5 : Expires: Mon, 1 Jan 2001 00:00:00 GMT
6 : Last-Modified: Wed, 08 Oct 2014 15:09:06 GMT
7 : Cache-Control: post-check=0, pre-check=0
8 : Pragma: no-cache

Thank you

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.