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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tim dot stebbing at nunatak dot com dot au
New email:
PHP Version: OS:

 

 [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: Fri May 17 11:01:34 2024 UTC