Hello Everybody, I've got a problem:
I'm writing a new WebApp without a Framework.
In my index.php im using: require_once('load.php');
and in * load.php* I'm using require_once('class.php');
to load my class.php.
In my class.php I've got this error:
Fatal error: Using $this when not in object context in class.php on line ... (in this example it would be 11)
An example how my class.php is written:
class foobar {
public $foo;
public function __construct() {
global $foo;
$this->foo = $foo;
}
public function foobarfunc() {
return $this->foo();
}
public function foo() {
return $this->foo;
}
}
In my index.php I'm loading maybe foobarfunc()
like this:
foobar::foobarfunc();
but can also be
$foobar = new foobar;
$foobar->foobarfunc();
Why is the error coming? Nothing found, never seen before in my other Webapps. Can anyone help me please?
EDIT: THANK YOU EVERYBODY! ALL OF YOU ARE RIGHT :)