使用 :: 声明的官方 PHP 文档 public 方法
Official PHP Doc public methods declared with ::
为什么官方 PHP 文档中的 public 函数使用普通静态函数“::”标记声明。
示例:
public DateInterval DateTime::diff ( DateTimeInterface $datetime2 [, bool $absolute = false ] )
官方 php 文档中此声明背后的含义是什么?
这意味着 DateTime 具有静态方法 diff 并且该方法 return 变量 DateInterval 类型。
当您记录 PHP 时,很难描述函数与其 class 之间的关系。所以他们使用 scope resolution operator 来表示该方法是 class 的一部分。这仅是为了记录。
这并不一定意味着函数是静态的。考虑 the mysqli function list. Almost none of those methods are static. If you read the class defintion you can see this. Also, a static method will say so in the documentation. For instance mysqli::poll
public static int mysqli::poll ( array &$read , array &$error , array &$reject , int $sec [, int $usec ] )
为什么官方 PHP 文档中的 public 函数使用普通静态函数“::”标记声明。 示例:
public DateInterval DateTime::diff ( DateTimeInterface $datetime2 [, bool $absolute = false ] )
官方 php 文档中此声明背后的含义是什么?
这意味着 DateTime 具有静态方法 diff 并且该方法 return 变量 DateInterval 类型。
当您记录 PHP 时,很难描述函数与其 class 之间的关系。所以他们使用 scope resolution operator 来表示该方法是 class 的一部分。这仅是为了记录。
这并不一定意味着函数是静态的。考虑 the mysqli function list. Almost none of those methods are static. If you read the class defintion you can see this. Also, a static method will say so in the documentation. For instance mysqli::poll
public static int mysqli::poll ( array &$read , array &$error , array &$reject , int $sec [, int $usec ] )