0

I'm extending Bankrekening and adding the variable $rente to it, the value of $rente should be determined by the function BerekenRente() which doesn't use any parameters and doesn't need to be initialized in the constructor parameters from my understanding. I get this error:

Parse error: syntax error, unexpected '(', expecting variable (T_VARIABLE) in C:\xampp\htdocs\SpaarBetaalrekening.php on line 55

This would refer to this line: public function __construct($naam, $rekeningnummer, $saldo, $kredietlimiet) {

class Spaarrekening extends Bankrekening{
    var $rente;

    public function __construct($naam, $rekeningnummer, $saldo, $kredietlimiet) {
        $this->naam = $naam;
        $this->rekeningnummer = $rekeningnummer;
        $this->saldo = $saldo;
        $this->kredietlimiet = $kredietlimiet;
        $this->rente = BerekenRente();
    }

    //Ontvang rente
    function OntvangRente(){
        $this->saldo = $saldo + BerekenRente();
    }

    function BerekenRente(){
        return ($this->saldo / 100) * 0.30;
    }
}

$rekening1 = new Spaarrekening("James", 5543, 600, 2000);
echo $rekening1->saldo;
Nutan
  • 21
  • 2
  • Your code runs fine here. It's likely something on the preceeding line. http://sandbox.onlinephpfunctions.com/code/8f1f4e967df13c8a7e17c288ac33357a127004a3 – ceejayoz Feb 25 '21 at 20:59
  • 1
    There are no syntax errors in this code, so you might have an unclosed paren earlier in the file. Also note that the two references to `BerekenRente()` should (probably) be `$this->BerekenRente()`. (Assuming that's the function you're referring to...) – Alex Howansky Feb 25 '21 at 21:00

0 Answers0