doujiang3997
2015-11-24 20:09
浏览 23
已采纳

如何在CodeIgniter中扩展多个类?

How can I extend multiple classes like this:

class Backend_api extends CI_Controller, Appointments
{
        do stuff...
}

图片转代码服务由CSDN问答提供 功能建议

如何扩展多个这样的类:

  class  Backend_api扩展了CI_Controller,Appointments 
 {
 do stuff ... 
} 
   
 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • douzi8548 2015-11-25 06:19
    已采纳

    As mentioned, multiple inheritance is not allowed in php, but if you need to access functions in the Appointments class, why not just create an instance of it in the class and call the function on that instance?

    $ins = new Appointments();
    $result = $ins->someFunction();
    
    已采纳该答案
    打赏 评论
  • dongshan4316 2015-11-24 20:11

    PHP does not support multiple inheritance

    打赏 评论
  • dqaxw44567 2015-11-24 20:13

    As already mentioned, PHP does not support multiple inheritance. But since PHP5.4 you can use traits and use them in your classes. More info about traits here

    打赏 评论

相关推荐 更多相似问题