php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #68219 Make http_response_code() also returns the text of response
Submitted: 2014-10-13 18:14 UTC Modified: 2023-10-14 22:52 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: ndschnbl at gmail dot com Assigned: bukka (profile)
Status: Assigned Package: Output Control
PHP Version: 5.5.17 OS: ANY
Private report: No CVE-ID: None
 [2014-10-13 18:14 UTC] ndschnbl at gmail dot com
Description:
------------
The http_response_code() function should return number (int) and text (string) of response. Currently only the int of the response code is output.

$http_response_headers works for streams in this way; http_response_code should also include this functionality.

Test script:
---------------
Current:

var_dump(http_response_code());

// int(200)


Suggested:

var_dump(http_response_code)());

// int(200)
// string(2) "OK"


Current: 

var_dump(http_response_code());

// int(301)


Suggested:

var_dump(http_response_code());

// int(301)
// string(17) "Moved Permanently"

Expected result:
----------------
HTTP/1.1 200 OK
HTTP/1.1 301 Moved Permanently
etc.

Actual result:
--------------
200
301

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-08-23 00:56 UTC] carusogabriel@php.net
-Summary: http_response_code() +Summary: Make http_response_code() also returns the text of response
 [2023-10-14 22:52 UTC] bukka@php.net
-Assigned To: +Assigned To: bukka
 [2023-10-14 22:52 UTC] bukka@php.net
I'm sorry but this does not make much sense in terms of the new return values. In any case I don't think we can change this function due to BC implication.

But I will leave it open as more request to easily expose response text which I would imagine as a completely new function
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC