attaboy Posted April 19, 2012 Share Posted April 19, 2012 What's undefined about deposit()? class BankAccount { private $name; var $balance = 0; private $dep = 0; function __construct() { if (array_key_exists ("deposit" , $_POST)) { $dep = $_POST['deposit']; echo $dep; deposit($dep); } } function deposit($dep) { $balance += $dep; echo $balance; } } Quote Link to comment https://forums.phpfreaks.com/topic/261222-call-to-undefined-function-deposit/ Share on other sites More sharing options...
requinix Posted April 19, 2012 Share Posted April 19, 2012 If you want to call an object's function you have to use $this-> (for instance methods). $this->deposit($dep); Quote Link to comment https://forums.phpfreaks.com/topic/261222-call-to-undefined-function-deposit/#findComment-1338652 Share on other sites More sharing options...
attaboy Posted April 19, 2012 Author Share Posted April 19, 2012 Oh! right no I get it....Thnaks! Quote Link to comment https://forums.phpfreaks.com/topic/261222-call-to-undefined-function-deposit/#findComment-1338836 Share on other sites More sharing options...
KevinM1 Posted April 19, 2012 Share Posted April 19, 2012 Also, a nitpick: don't use the 'var' keyword. PHP 5 has three official access modifiers - public, protected, and private. Quote Link to comment https://forums.phpfreaks.com/topic/261222-call-to-undefined-function-deposit/#findComment-1338840 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.