Req #67029 [NEW]: feature-request: user defined superglobals

From: Date: Sat, 05 Apr 2014 15:45:30 +0000
Subject: Req #67029 [NEW]: feature-request: user defined superglobals
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185112@lists.php.net to get a copy of this message
From: php at richardneill dot org Operating system: PHP version: Irrelevant Package: Variables related Bug Type: Feature/Change Request Bug description:feature-request: user defined superglobals Description: ------------ When writing a complex web application, it is useful to put common configuration settings, strings, database-connection resources, etc into an array, such as $APPLICATION. However, it's then necessary to pull this in with "global $APPLICATION" into every single function. This leads to uglier code. Test script: --------------- global $X; #wish: *push* X into the global scope. $X = 42; function testit () { //global $X; #wish: not required to pull in $X here. echo "X is $X"; } function testit2 () { //global $X; #... or here, or in 100 other places. echo "X is $X"; } testit(); testit2); etc Expected result: ---------------- It would be a useful enhancement to have one of the following: * allow variables to be "pushed" into the global scope, rather than needing to be pulled in by each function (i.e. declare the variable as global just once in the main body, rather than every single time it's needed in a function). * have a mechanism to create user-defined superglobals (it's currently documented as being explicitly not allowed). * have PHP pre-create an empty superglobal such as $_APP[] or $_USER[] which is reserved for the user to do as he wishes. Thanks for your time - I hope this suggestion is helpful. -- Edit bug report at https://bugs.php.net/bug.php?id=67029&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67029&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67029&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67029&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=67029&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=67029&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=67029&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=67029&r=needscript Try newer version: https://bugs.php.net/fix.php?id=67029&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=67029&r=support Expected behavior: https://bugs.php.net/fix.php?id=67029&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=67029&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=67029&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=67029&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67029&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=67029&r=dst IIS Stability: https://bugs.php.net/fix.php?id=67029&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=67029&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=67029&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=67029&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=67029&r=mysqlcfg

« previous php.bugs (#185112) next »