I'm reading this tutorial about PHP Classes. I haven really fully understand it, can anyone help me out here? I came across this class
<?php
class foo{
private $_var;
static function bar(){
return $this->_var;
}
function setVar($value = null){
$this->_var = $value;
}
}
?>
It says there's something wrong with the class. Is it that obvious? I dont know what's wrong with it... is it the underscore before the var? Edit: if I run this code
$x = new foo();
$x->setVar(1);
echo $x->bar();
I get this message Fatal error: Using $this when not in object context in main.php on line 6 PHP Fatal error: Using $this when not in object context in main.php on line 6