Created
July 1, 2010 05:34
-
-
Save aaronpk/459618 to your computer and use it in GitHub Desktop.
Unexpected access to a protected object property in PHP
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 | |
highlight_file(__FILE__); | |
echo '<hr />'; | |
class A | |
{ | |
protected $_x = 100; | |
public static function getX() | |
{ | |
$a = new A(); | |
return $a->_x; | |
} | |
} | |
class B | |
{ | |
public static function getX() | |
{ | |
$a = new A(); | |
return $a->_x; | |
} | |
} | |
$a = A::getX(); | |
var_dump($a); | |
$b = B::getX(); | |
var_dump($b); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also on flickr here: http://www.flickr.com/photos/aaronpk/4750687049/