Page 1 of 1

Accessing class members

Posted: Mon Dec 18, 2006 5:04 pm
by evilmonkey
Hello all,

In my continuing quest to rewrite my code in OOP (I'm in the beginning stages), I would like to know the difference between "->" and "::". For instance:

Code: Select all

class Foo{
public string = "string";
function write(){
echo "Hello, I'm a ".$this->string;
}
}

$bar = new Foo();
$bar->write();
So when would I need to use "::"?

Thanks. :)

Posted: Mon Dec 18, 2006 5:37 pm
by feyd
-> is for instances
:: is for statics.

Posted: Mon Dec 18, 2006 6:00 pm
by m3mn0n

Posted: Mon Dec 18, 2006 7:45 pm
by evilmonkey
feyd wrote:-> is for instances
:: is for statics.
That...makes sense. Thanks. :) (And m3mn0n, I read the page you pointed me to before posting this. I do some research, not a total n00b here. :) )