开发者

Why are dynamic class methods specified with the double colon notation?

开发者 https://www.devze.com 2023-02-14 22:32 出处:网络
This is puzzling me: http://php.net/manual/en/开发者_开发问答dateinterval.format.php public string DateInterval::format ( string $format )

This is puzzling me: http://php.net/manual/en/开发者_开发问答dateinterval.format.php

public string DateInterval::format ( string $format )

The method is not static, yet it is given the double colons. What's the reasoning here?


That's nothing more than PHP authors'/developers' way of writing a method name qualified by its class. It isn't related to the static/dynamic nature of a method.

You'll spot this notation in PHP's errors as well. For example,

$o = new stdClass;
$o->method();

produces this error:

Fatal error: Call to undefined method stdClass::method()

0

精彩评论

暂无评论...
验证码 换一张
取 消