|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-04-05 21:58 UTC] requinix@php.net
-Status: Open
+Status: Wont fix
[2014-04-05 21:58 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 12 11:00:01 2025 UTC |
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.