Page 1 of 1

Extension of PEAR classes.

Posted: Thu Jun 13, 2013 6:00 am
by cortazar11
Hello,

I am trying to extend a class from the package Math_Finace in PEAR.
As a trial the only thing I am doing is to write the extended class like this:

class Math_Finance_Inher extends Math_Finance {
function newPresentValue() {
return "A string";
}
}

in a separate file under the file where is the base class.
Afterwards, I create a object:
$var = new Math_Finance_Inher();
and I tried to get the value of newPresentValue();
echo $var -> newPresentValue();

but nothing is returned, though there are not errors either.
Am I missing something?

Thank you.

Re: Extension of PEAR classes.

Posted: Thu Jun 13, 2013 12:32 pm
by requinix
There's something else going wrong.

1. Are you sure you have display_errors=on and error_reporting=-1? If not then you might not see all the errors.
2. Is your script crashing? Perhaps because it can't find the class?
3. Are you missing silly little things like <?php tags?

Re: Extension of PEAR classes.

Posted: Fri Jun 14, 2013 3:26 am
by cortazar11
Thank you for the answer.

That is right. I didn't put on the display_errors.
The error is that the base class is not found.

I sorted. As the inherited class was in different file, I needed to call that first through the require command.

Thank you.