Simply put, ::
is for class-level properties, and ->
is for object-level properties.
If the property belongs to the class, use ::
If the property belongs to an instance of the class, use ->
class Tester
{
public $foo;
const BLAH;
public static function bar(){}
}
$t = new Tester;
$t->foo;
Tester::bar();
Tester::BLAH;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…