dongqie2028 2016-06-05 14:48
浏览 69

在Codeigniter中加载库时出现PHP错误

I've included the ColorsOfImage PHP class from humanmade into my Codeigniter as a new library.

Now when I load the library in a controller, I can use the functions of the class without any problems, but I always get the following error when loading the library, which says, that the $image in the __construct function is empty!?

Here is the __construct function of the class:

public function __construct( $image, $precision = 10, $maxnumcolors = 5, $trueper = true ) {
        $this->image = $image;
        $this->maxnumcolors = $maxnumcolors;
        $this->trueper = $trueper;
        $this->getImageSize();
        $this->precision = $precision;
        $this->readPixels();
        $this->_excluded_colors[] = $this->getBackgroundColor();
    }
  • 写回答

1条回答 默认 最新

  • dswqz24846 2016-06-05 15:06
    关注

    You should check docs where is said:

    library($library[, $params = NULL[, $object_name = NULL]])
    

    Parameters:

    • $library (mixed) – Library name as a string or an array with multiple libraries
    • $params (array) – Optional array of parameters to pass to the loaded library’s constructor
    • $object_name (string) – Optional object name to assign the library to

    In case of CI using custom library with constructor parameters from a controller:

    $this->load->library('colorsofimage', [$image, $precision = 10, $maxnumcolors = 5, $trueper = true]);
    
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改