【发布时间】:2014-12-08 11:36:10
【问题描述】:
为什么“扩展”和“实现”的顺序很重要? !!!
例如
正确的顺序first:"extends" second:"implements"
顺序错误first:"implements" second:"extends"
正确的顺序
// first:"extends" second:"implements"
// works fine
class Student extends Person
implements Student_Interface {
// ....
}
错误的顺序
// first:"implements" second:"extends"
// Give us
// Parse error: syntax error, unexpected T_EXTENDS, expecting '{'
class Student implements Student_Interface
extends Person {
// ....
}
【问题讨论】:
-
因为 PHP 核心开发团队认为这很重要!
-
为什么
str_replace不是string_replace? -
这是您必须遵循的标准。意思是问为什么
-
为什么 array_search() 的命令或参数是 needle/haystack 而不是 haystack/needle?
标签: php oop inheritance implementation