Hi folks,
please take a look at this:
class MyClass1 {
var $i=0;
...
}
class MyClass2 {
var $x=0.0;
var $obj;
function MyClass2() {
$this->obj = new MyClass1();
}
function anotherFunction() { ...
};
...
}
function getObjects(&$resultSet) {
// just for simplicity
// accessing a database in real life
$obj = new MyClass2
$resultSet[] = $obj;
}
...
getObjects($result);
$o = (object)$result[0];
// var_dump($o);
$o->anotherFunction();
The last line causes an "Fatal error: Call to undefined function: anotherfunction()"
The same code worked with php3 but doesn't with php4 any more.
I guess the problem is that i use a typecast to object (which doesn't have a function anotherFunction) und not to MyClass2. But as far as I know php4 doesn't support typecasts to MyClass2.
Do you have an idea on how to solve this problem ?
Thx Peter
P.S: var_dump($o) looks ok. All data seems to be there.