My code was dying on the line below where I use method_exists:
if (class_exists($ nameOfClassToBe Used)) {
$object = new $nameOfClassToB eUsed();
$this->arrayOfAllTheO bjectsSoFarLoad ed[$nameOfClassToB eUsed] = &
$object;
if (method_exists( $object, "setCallingCode "))
$object->setCallingCode ($nameOfFunctio nOrClassCalling );
return $object;
} else {
$this->error("$nameOf ClassToBeUsed not found. The code that wants
this class is $nameOfFunction OrClassCalling ");
}
The method is in the parent class yet I'd forgotten to call parent:: in
the constructor of the child class. It seems to me that method_exists
was testing true, though the method was not truly available, and then
the code died. Adding parent:: to the constructor of the child solved
the problem. Is this a bug in PHP?
if (class_exists($ nameOfClassToBe Used)) {
$object = new $nameOfClassToB eUsed();
$this->arrayOfAllTheO bjectsSoFarLoad ed[$nameOfClassToB eUsed] = &
$object;
if (method_exists( $object, "setCallingCode "))
$object->setCallingCode ($nameOfFunctio nOrClassCalling );
return $object;
} else {
$this->error("$nameOf ClassToBeUsed not found. The code that wants
this class is $nameOfFunction OrClassCalling ");
}
The method is in the parent class yet I'd forgotten to call parent:: in
the constructor of the child class. It seems to me that method_exists
was testing true, though the method was not truly available, and then
the code died. Adding parent:: to the constructor of the child solved
the problem. Is this a bug in PHP?
Comment