ID: 50411 Updated by: col...@php.net Reported By: dkr at mindwerk dot de Status: Open Bug Type: Scripting Engine problem Operating System: linux 2.6.21 PHP Version: 5.2.11 New Comment:
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 Previous Comments: ------------------------------------------------------------------------ [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/?id=50411&edit=1