set_http_response_code() to PHP5.4 ?
| From: | Julien Pauli | Date: | Fri, 10 Jun 2011 12:11:33 +0000 |
| Subject: | set_http_response_code() to PHP5.4 ? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-53237@lists.php.net to get a copy of this message | ||
Hey,
I've seen Kalle's patch for http://bugs.php.net/bug.php?id=52555.
It actually implements a http_response_code() function to export the
current HTTP response code from SAPI layer to PHP user land.
I'm suggesting to rename that function to get_http_response_code(),
and implement its sister : set_http_response_code().
Something like that should make it :
PHP_FUNCTION(set_http_response_code)
{
long code;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &code) == FAILURE)
return;
sapi_header_op(SAPI_HEADER_SET_STATUS, &code TSRMLS_CC);
RETURN_TRUE;
}
That would help changing the http response code.
Actually, that can only be done in weird ways, like <?php header(' ',
null, 301); ?>
Julien