Doc #50411 [Opn->Csd]: less important: global and static in global scope

From: Date: Thu, 10 Feb 2011 15:27:59 +0000
Subject: Doc #50411 [Opn->Csd]: less important: global and static in global scope
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-5965@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=50411&edit=1 ID: 50411 Updated by: vrana@php.net Reported by: dkr at mindwerk dot de Summary: less important: global and static in global scope -Status: Open +Status: Closed Type: Documentation Problem Package: Variables related Operating System: linux 2.6.21 PHP Version: 5.2.11 -Assigned To: +Assigned To: vrana Block user comment: N Private report: N New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2009-12-08 14:26:57] colder@php.net global scope != at the main scope of your file. Remember that a file could be included in a function's scope. But sure, it doesn't make much sense to have those in the real global scope, not sure it's worth a runtime notice/warning though ------------------------------------------------------------------------ [2009-12-08 13:51:22] dkr at mindwerk dot de Description: ------------ Hi! Either its some documentation problem or a error reporting problem, but "static" and "global" can be used in the global scope, and this makes no sense? Or is it some kind of: make statics or globalize variables in a file included in a function in another file? if so, close this bugreport and eventually make some documentation for that... :) thx and greets Reproduce code: --------------- <?php error_reporting(E_ALL); # The php doc says "A static variable exists only in a local function scope" # but this does not fail in any way: static $test = 1; echo("test for static successfull\n"); # As global does only makes sense within the function, this should fail # also with some error or something: global $test2; echo("test2 for global successfull\n"); Expected result: ---------------- Any error message like "The keyword static|global is not allowed in global scope" Actual result: -------------- test for static successfull test2 for global successfull ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=50411&edit=1

« previous php.doc.bugs (#5965) next »