开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜