Edit report at http://bugs.php.net/bug.php?id=52439&edit=1
ID: 52439
Comment by: shiranai7 at hotmail dot com
Reported by: shiranai7 at hotmail dot com
Summary: Static and non-static variable name collision in a
class declaration
Status: Bogus
Type: Bug
Package: Class/Object related
Operating System: Win
PHP Version: 5.3.3
New Comment:
Not a bug? What is this supposed to be then? Correct behavior? I think
not. This is not a "support question". I am just reporting that PHP
behaves wrong - treats static and non-static variable as one in first
example.
Do I really have to explain that static variable is not THE SAME as
non-static variable and that I am NOT redeclaring anything? Duh.
And - if you are about to reply with another silly predefined answer
then better don't answer at all, thank you.
Previous Comments:
------------------------------------------------------------------------
[2010-07-25 17:50:44] [email protected]
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2010-07-25 17:48:33] shiranai7 at hotmail dot com
Description:
------------
It seems impossible to have two variables - one static and one not -
with same name in a class declaration. But these are two completely
different variables!
Test script:
---------------
<?php
// this results in a fatal error
class Test {
public static $Foo = 'iamstatic';
public $Foo = 'iamNOTstatic';
}
// this works
class Test {
public static $Foo = 'iamstatic';
}
$Baz = new Test();
$Baz->Foo = 'iamNOTstatic';
echo $Baz->Foo."\n";
echo Test::$Foo;
/* Result:
iamNOTstatic
iamstatic
*/
?>
Expected result:
----------------
No errors.
Actual result:
--------------
Fatal error: Cannot redeclare Test::$Foo in *path* on line 6
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52439&edit=1