balance . '
'; // Ovako pristupamo vrednosti balance 'pravimo referencu'
}
public function Withdraw($amount)
{
if ($this->balance < $amount) {
echo 'Not enough money
';
} else {
$this->balance = $this->balance - $amount;
}
}
public function Deposit($amount){
$this->balance = $this->balance + $amount;
}
}
//Multiple instances of class :
$alex = new BankAccount;
$billy = new BankAccount;
$alex -> Deposit(100);
$billy -> Deposit(50);
$alex -> Withdraw(98);
$billy -> Withdraw(12.5);
echo $alex -> DisplayBalance();
echo $billy -> DisplayBalance();
?>