静态延迟绑定,参数的类型约束,对象的遍历.docx

静态延迟绑定,参数的类型约束,对象的遍历.docx

静态延迟绑定,参数的类型约束,对象的遍历

静态延迟绑定,static问题:1:$this 永远代表所在类的对象?????不是2:self 永远代码所在类吗?????是如:class?P?{ public?static?$where?=?in?P?static?preperty?lt;br?/gt;; public?static?function?sayWhere()?{ echo?self::$where; } } class?C?extends?P?{ public?static?$where?=??in?C?static?preperty?lt;br?/gt;; } echo?P::sayWhere(); echo?C::sayWhere();输出结果为:in?P?static?preperty? in?P?static?preperty显然,当前的逻辑不是十分完善此时,应该是表示当前类的关键字,最好应该在调用时决定最好(self 办不到)此时,采用一个新的关键字,代表当前类,与 selft 不同,在于是 运行时调用房室,而不在类编译时就确定好了的!关键字是:static示例:class?P?{ public?static?$where?=?in?P?static?preperty?lt;br?/gt;; public?static?function?sayWhere()?{ echo?self::

文档评论(0)

1亿VIP精品文档

相关文档