php - Fatal error: Cannot use [] for reading -
i'm getting error
fatal error: cannot use [] reading in... on line 26
checking threads have been made here on error, still cannot figure out. looking @ code there's nothing i'm doing wrong.
<?php class person { //variables personal information// private $navn; private $adresse; private $postnummer; private $poststed; private $telefonnummer; private $fodselsdato; public function __construct($navn, $adresse, $postnummer, $poststed, $telefonnummer, $fodselsdato) { $this->navn = $navn; $this->adresse = $adresse; $this->postnummer = $postnummer; $this->poststed = $poststed; $this->telefonnummer = $telefonnummer; $this->fodselsdato = $fodselsdato; } //creates array store education person// private $utdanning = array(); //function add education array// public function leggtilutdanning(utdanning $utdanning) { $this->utdanning[] = $utdanning; } } //class education class utdanning { private $institusjon; private $studieretning; private $grad; private $startet; private $ferdig; public function __construct($institusjon, $studieretning, $grad, $startet, $ferdig) { $this->institusjon = $institusjon; $this->studieretning = $studieretning; $this->grad = $grad; $this->startet = $startet; $this->ferdig = $ferdig; } } $person1 = new person('dave lewis', 'downing street 14', 0442, 'northville', 98765432, '17.05.1975'); $utdanning = new utdanning('harvard', 'economics', 'bachelor', 2013, 2016); $person1->leggtilutdanning($utdanning); ?> the error comes line inside function i'm trying add utdanning-object array. it's funny, cause tried same method of doing on project, using exact same syntax, , worked perfectly. furthermore, don't understand why says i'm trying read array, when i'm adding it.
does have idea what's going on here?
edit: circled problem , made more simple version of code can see yourself.
so, mark solved, got rid of problem rewriting characters inside method leggtilutdanning. appears have been sort of character encoding-problem pointed out, have absolutely no idea how happened. anyway, help.
Comments
Post a Comment