php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #22972 Addition to the global keyword
Submitted: 2003-03-30 23:08 UTC Modified: 2003-04-01 02:15 UTC
From: tim dot stebbing at nunatak dot com dot au Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.3.1 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2003-03-30 23:08 UTC] tim dot stebbing at nunatak dot com dot au
optionaly add 'as' to the global keyword, in the same way that SQL 'as' works:

global $aVeryLongVariableName as $foo

It would neaten alot of code, would not break old scripts, I imagine your passing a ref into the code block, this is just specifying the handle used :) 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-01 02:15 UTC] pollita@php.net
The general consensus seems to be that this feature will not be added.  A simple workaround which you can implement in your code to achieve the 'neatening up' you're going for is:

function bar() {
  global $aVeryLongVariableName;
  $foo = &$aVeryLongVariableName;

  /* This will successfully increment the value of $aVeryLongVariableName */
  $foo++;
}
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 15:01:33 2024 UTC