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
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:
50 - 36 = ?
Subscribe to this entry?

 
 [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 07:01:32 2024 UTC