Bug #16185 Updated: global required in functions

From: Date: Wed, 20 Mar 2002 14:58:22 +0000
Subject: Bug #16185 Updated: global required in functions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-2959@lists.php.net to get a copy of this message
ID: 16185 Updated by: rasmus@php.net Reported By: adam@adeptsoftware.com -Status: Open +Status: Closed Bug Type: Feature/Change Request Operating System: WinXP PHP Version: 4.1.2 New Comment: This simply will not change. It is a characteristic of the language. Perhaps you shouldn't be using 20 global variables? See http://marc.theaimsgroup.com/?l=php-general&m=97984136422910&w=2 Previous Comments: ------------------------------------------------------------------------ [2002-03-20 09:51:10] adam@adeptsoftware.com "In PHP global variables must be declared global inside a function if they are going to be used in that function." I really think PHP should not be different from C here - or at least there should be a setting for this. Even something like "global ALL;" would be better, but not ideal. The most common problem I run into by FAR is variables not being available in the local scope. Making me register 20 of them as global by name in every single function is counterproductive and goes against the idea of keeping code as simple as possible. Your justification for this is: "This can cause some problems in that people may inadvertently change a global variable." That is a very rare problem compared to the new problem this has introduced. JavaScript handles this better, requiring declaration with "var" to force a variable to be local only. I would much prefer this, and PHP doing it the way every other language does would also be preferable. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16185&edit=1

« previous php.bugs (#2959) next »