【问题标题】:Order of "extends" and "implements" in PHP class?PHP类中“扩展”和“实现”的顺序?
【发布时间】: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


【解决方案1】:

据我了解,cmets
这与 Core PHP Language Syntax

有关

【讨论】:

    猜你喜欢
    • 2014-04-21
    • 2017-07-25
    • 2012-10-25
    • 2012-06-06
    • 2018-04-29
    • 1970-01-01
    • 2015-06-02
    • 2012-01-10
    相关资源
    最近更新 更多