简体   繁体   English

如何将我的自定义库扩展到我的控制器

[英]How to extend My custom library to my controller

I want my Custom_library class extend to My_custom_controller . 我想将Custom_library类扩展到My_custom_controller Is it possible? 可能吗?

If you want to extend simply extend: 如果要扩展,只需扩展:

class xyz extends utv
{
    //class code here
}

But I advise you to load library in constructor to private $var in your controller 但我建议您将构造函数中的库加载到控制器中的私有$ var中

class My_custom_controller
{
    private $libs;
    public function __construct()
    {
         $this->libs = new Custom_library();
    }
}

I advise you that becouse you really don't want to extend library in controller, you can override something by accident, that way you will have access to library and you will be shure that nothing wrong goes with your library 我建议您,因为您确实不想在控制器中扩展库,您可以偶然覆盖某些内容,这样您就可以访问库,并且可以确保库没有任何问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM