- 1
17th Jun 2021, 12:10 AM
Sash The Smartest Alien
Sash The Smartest Alien - avatar
3 Antworten
+ 2
Sash Sillah 1) your class definition and access to it must be separated... you wrote: class myNiggers { /* ... */ $myniggers = new myNiggers(); } but should be: class myNiggers { /* ... */ } $myniggers = new myNiggers(); the class closing bracket must be before trying to create an instance 2) your __construct method takes 3 arguments, so you are required to pass 3 argument by calling new class: $myniggers = new myNiggers("","",""); 3) if you want to use your getXXX methods, you must acess property by $this->xxx and not $this->$xxx... also, for getting the values as result of function call, you must use the return keyword: public function getName(){ return $this->name; } not: public function getName(){ $this->$name; } similary for both other getXXX functions ;) however, getters and setters are not mandatory: you could access public properties from outside as: $myniggers->address = "foo bar"; echo $myniggers->address;
17th Jun 2021, 1:12 AM
visph
visph - avatar
0
Thanks
17th Jun 2021, 9:57 AM
Sash The Smartest Alien
Sash The Smartest Alien - avatar
0
Thanks
17th Jun 2021, 9:58 AM
Sash The Smartest Alien
Sash The Smartest Alien - avatar