Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我总是写:
$object->method
但我经常看到:
$object::method
有什么不同?
-> 在引用对象的成员时使用。
:: 是范围解析运算符,用于引用类的静态成员。例如
class test { public static function vehicle() { echo "Bus"; } public function automobile() { echo "Car"; } }
您将调用函数汽车()为
$test = new test(); $test->automobile();
并且您将车辆功能称为
test::vehicle();