在 Codeigniter 中加载库时传递参数
Passing parameter when loading Library in Codeigniter
我正在尝试集成 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;
}
}
}
基本上我在函数中传递了 array 并尝试将 获取为变量。现在我已经通过获取 array()
解决了这个问题
我正在尝试集成 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;
}
}
}
基本上我在函数中传递了 array 并尝试将 获取为变量。现在我已经通过获取 array()
解决了这个问题