php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25341 Parse error if using server variables as default function argument value
Submitted: 2003-09-01 06:57 UTC Modified: 2003-09-01 07:04 UTC
From: martin at lucas-smith dot co dot uk Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.3.3 OS: Win2K
Private report: No CVE-ID: None
 [2003-09-01 06:57 UTC] martin at lucas-smith dot co dot uk
Description:
------------
Is there some reason why a $_GET or other server variable cannot be included directly within a function declaration, as its default value?

If using the reproduce code below I get a parse error:

Parse error: parse error, unexpected T_VARIABLE in [scriptaddress] on line [linenumber]


Reproduce code:
---------------
function queryParameters ($queryString = $_GET['QUERY_STRING'])
{
	# Do something with $queryString
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-01 06:58 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

It has nothing to do with it being a superglobal or not. You just can ONLY use constants as default values.

Derick
 [2003-09-01 07:03 UTC] martin at lucas-smith dot co dot uk
Is this a deliberate restriction? It seems a perfectly reasonable thing to want to do. Perhaps this is a feature request then..
 [2003-09-01 07:04 UTC] derick@php.net
Yes, this is deliberate because it's hard to chose from which scope to pick the variables from (calling, or called). Don't bother with a feature request, it won't be changed anyway.

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 05 04:01:29 2024 UTC