Created
June 3, 2013 16:28
-
-
Save taq/5699377 to your computer and use it in GitHub Desktop.
Stupid PHP static variables behaviour
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class A { | |
public static $name = null; | |
} | |
A::$name = "a"; | |
class B extends A { | |
} | |
B::$name = "b"; | |
// both return b! | |
echo A::$name."\n"; | |
echo B::$name."\n"; | |
?> |
Depois de 4 anos que vejo o comentário ... :-p
Na verdade, @viniciusgati, aí não leva em conta a herança, pois você está declarando novamente todas as variáveis na classe filha ...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assim fica feio?