I have really started to look at PHP Classes, and I can not understand why this does not work. I thought if you define a variable in the constructor you can call it by that variable name. That is not the case though(?), let me give you all an example:
class test {
public function __construct($item) {
$this->item= $anItem;
}
public function callvar() {
//Does not work
return $anItem;
}
public function callvar() {
//Works
return $this->item;
}
}
So my question is, am I doing something wrong? Or must you call a __construct variable by $this->item?