PHP Scope Resolution Operator Question
Posted
by anthony
on Stack Overflow
See other posts from Stack Overflow
or by anthony
Published on 2010-04-02T18:17:23Z
Indexed on
2010/04/02
18:23 UTC
Read the original article
Hit count: 425
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.
© Stack Overflow or respective owner