PHP Scope Resolution Operator Question
- by anthony
I'm having trouble with the MyClass::function(); style of calling methods and can't figure out why. Here's an example (I'm using Kohana framework btw):
class Test_Core
{
public $var1 = "lots of testing";
public function output()
{
$print_out = $this->var1;
echo $print_out;
}
}
I try to use the following to call it, but it returns $var1 as undefined:
Test::output()
However, this works fine:
$test = new Test();
$test->output();
I generally use this style of calling objects as opposed to the "new Class" style, but I can't figure out why it doesn't want to work.