php class not working

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
User avatar
Regit
Forum Newbie
Posts: 11
Joined: Tue Oct 10, 2006 7:36 am
Location: Here, there, everywhere

php class not working

Post by Regit »

I am trying to use the following class to produce the npv (Net Pressent Value) of some numbers. I am using this for a custom app for our accounting office.

Code: Select all

class npv {

	function calcNPV($rate, $values) { 
		for ($i=0;$i<=count($values);$i+=1) { 
			$npv = $values[count($values) - $i] + $npv / (1 + $rate); 
		} 
		return $npv; 
	} 

}

// using the function
$npv = new npv();
print $npv->calcNPV(0.09, array(0,30,40,50,60,70));
what am I doing wrong, or is there another way to calculate NPV?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Could you help us help you by stating the problem a little more clearly%AC What is not working%AC How is it not working%AC Please be specific.
User avatar
Regit
Forum Newbie
Posts: 11
Joined: Tue Oct 10, 2006 7:36 am
Location: Here, there, everywhere

Post by Regit »

Yes sorry, All that happens is it prints

calcNPV(0.09, array(0,30,40,50,60,70)); } ?>

to the screen, it doesnt print the npv value
User avatar
Regit
Forum Newbie
Posts: 11
Joined: Tue Oct 10, 2006 7:36 am
Location: Here, there, everywhere

Post by Regit »

We'll I figured out what I needed to do, so there is now no problem. Thx for trying to help though, i appreciate it
Post Reply