On 1 December 2014 22:28:04 GMT, Ralph Schindler <ra...@ralphschindler.com> 
wrote:
>Hi all,
>
>Many of you know from reading the subject line whats coming next! ;)
>
>In php, after we interact with HTTP streams (as a client), PHP conjures
>
>into local scope a variable with header information from the previous 
>request $http_response_header.  Is this behavior something we want to 
>keep around into PHP 7? Or should we find a different/short-cut way to 
>get the information.
>
>Currently, the same information can be ascertained, but only if there
>is 
>an open file handle and only through stream_get_meta_data($fh).
>
>It would be nice if there were an as-easy approach to getting data 
>without perhaps conjuring magic variables into the beloved local scope?
>
>Thoughts?
>Ralph Schindler
>
>PS Also, do we have any other local-scope variables like this?

Wow, I had no idea that existed; what an incredibly ugly implementation. Even 
the name is weird (why "header" singular when it contains an array of headers?)

The only other local-scope variable listed next to it in the manual [1] is 
$php_errormsg, which has to be enabled with an ini setting.

If the information is useful at all, then I guess a 
get_last_http_response_headers() function would be less magic - although that 
would presumably mean the data had to be stashed indefinitely in an internal 
global just in case it was asked for, rather than it naturally falling out of 
scope.

We could just say that if you're using a shortcut like file_get_contents, you 
can't have it both ways and access metadata afterwards. It's just a pity 
ext/curl is so faithful to the underlying lib, and therefore so awkward to use 
for simple cases.

[1]: http://php.net/manual/en/reserved.variables.php



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to