JAVA developer send me data in headers. I take it this way
$_SESSION["HTTP_COUNTRYNAME"];
How to make response back with headers? It tried header("countryname: USA");
but php function headers_list
doesn't show it.
The header() function is an predefined PHP native function. With header() HTTP functions we can control data sent to the client or browser by the Web server before some other output has been sent. The header function sets the headers for an HTTP Response given by the server.
The get_headers() function in PHP is used to fetch all the headers sent by the server in the response of an HTTP request. Parameters: This function accepts three parameters as mentioned above and described below: $url: It is a mandatory parameter of type string.
PHP | header() Function. The header() function is an inbuilt function in PHP which is used to send a raw HTTP header. The HTTP functions are those functions which manipulate information sent to the client or browser by the Web server, before any other output has been sent.
The Content-Type header is used to indicate the media type of the resource. The media type is a string sent along with the file indicating the format of the file. For example, for image file its media type will be like image/png or image/jpg, etc. In response, it tells about the type of returned content, to the client.
header('countryname: USA');
print_r(headers_list());
Array ( [0] => X-Powered-By: PHP/5.3.0 [1] => countryname: USA )
...works for me.
Are you sure you haven't output anything before it? You cannot set headers after you've started printing text. Use headers_sent()
to see if the headers have already been sent (that is, if you've already output something).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With