【问题标题】:Passing parameter when loading Library in Codeigniter在 Codeigniter 中加载库时传递参数
【发布时间】:2021-09-06 18:26:19
【问题描述】:

如果我在加载库时通过三个它不起作用,我正在尝试集成 textlocal 短信 api。

错误:函数 Textlocal::__construct() 的参数太少,通过了 1 个,预期至少有 2 个

我有一个如下的 Setupfile.php 库。

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Setupfile {

  function send($number, $message)
  {

    $ci = & get_instance();
    $data=array("username"=>'xyz',"hash"=>'abc','apiKey'=>false);
    $sender  = "xyz";
    $numbers = array($number);
    $ci->load->library('textlocal', $data); //passing paramenters

  }
}

还有一个Textlocal.php库如下:

class Textlocal
{

    function __construct($username, $hash, $apiKey = false) //get into this function
    {

        $this->username = $username;
        $this->hash = $hash;
        if ($apiKey) {
            $this->apiKey = $apiKey;
        }

    }
}

【问题讨论】:

    标签: php codeigniter parameter-passing textlocal


    【解决方案1】:

    基本上我在函数中传递了和数组,并尝试获取作为变量。现在我已经解决了这个问题,得到了一个数组()

    【讨论】:

      猜你喜欢
      • 2011-03-29
      • 2012-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-07
      • 1970-01-01
      • 2020-12-03
      相关资源
      最近更新 更多