- 1
I need help in this code, please!
3 odpowiedzi
+ 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;
0
Thanks
0
Thanks