I’ve implemented the magic functions __get() and __set():
function __get($property) {
if(isset($this->$property)) {
return $this->$property;
} else {
return null;
}
}
function __set($property, $value) {
$this->$property = $value;
}
The following code works fine:
$connect->Hammer = "DoubleClawed";
echo $connect->Hammer;
However, when I run some of my unit tests, the line:
$this->Id = (int) $configXML->ConfigurationFindResults->Configuration->Id;
Gives me:
Trying to get property of non-object
There are other magically set variables before that that work. I’ve also tested this code using non-magic methods and it works. Why does this line set it off? ($configXML is a SimpleXML object)
Your magic
__getand__setlook fine to me. (I use the same code in my app).Your error comes form
$configXML->ConfigurationFindResults->Configuration->Id;