php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #76008 Add parameters to getallheaders or apache_request_headers
Submitted: 2018-02-25 23:49 UTC Modified: 2018-02-25 23:59 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: valentiny510 at gmail dot com Assigned:
Status: Open Package: Apache related
PHP Version: 7.2.2 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
10 - 3 = ?
Subscribe to this entry?

 
 [2018-02-25 23:49 UTC] valentiny510 at gmail dot com
Description:
------------
array getallheaders ( void )
array apache_request_headers ( void )

... We already have many ways to get some header if need,
apache_request_headers, getallheaders are the same...
$_SERVER, $_REQUEST, $_ENV, $GLOBALS (if not unset), etc..

Is full of arrays all over the place and there is no way to get some variable without using "isset" (aside: I think isset is the most used word in PHP)
I know we can use $_SERVER['whatever'] ?? null
but for once whould be nice to have a function that return null for us
by default in case it not exists..

My request is to add a new parameter to any of that function
getallheaders/apache_request_headers($header_name = null),
or create a new function, i.e. getheader(string $name = null/void)
will be much faster if is implemented in the core, and easier to work with..
if ('php.net' = getheader('host'))
    do something...
instead of
$headers = getallheaders( );
if (isset($headers['Host']) && $headers['Host'] == 'php.net')
    do something...

you got the idea... Thank you



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-25 23:59 UTC] valentiny510 at gmail dot com
P.S. Allowing case insensitive for both, of course,
the string to compare with (php.net), and the parameter (Host|host|HOST)
if ('php.net' = getheader('host'))
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 13:01:30 2024 UTC