Consider this code:
<?
class MyClass {
var $blah;
function MyClass() {
$this->blah = '';
}
function getBlah() {
return $this->blah;
}
function setBlah($blah) {
$this->blah = $blah;
}
}
Here is the question I have for you guys, is this a PHP bug?
<?
$foo =& new MyClass;
$foo->setBlah('hello world');
print_r($foo->blah . "<P>");
// PRODUCES FATAL ERROR: print_r($foo->getBlah() . "<P>");
$foo = null;
?>
If I uncomment the "FATAL ERROR" line above I literally get this fatal error:
Fatal Error: method called upon a non-object in line...
I talked to a PHP guru and he wasn't sure of the behavior either. Perhaps I am missing something about class behavior in PHP but this makes absolutely no sense to me. Can someone else out there figure out if either something is wrong with my class structure or nothing is wrong and PHP has a bug in its class features?
Thanx
Phil