Extension of PEAR classes.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cortazar11
Forum Newbie
Posts: 10
Joined: Mon Nov 14, 2011 1:48 pm

Extension of PEAR classes.

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Extension of PEAR classes.

Post 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?
cortazar11
Forum Newbie
Posts: 10
Joined: Mon Nov 14, 2011 1:48 pm

Re: Extension of PEAR classes.

Post 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.
Post Reply