function index()
{
$this->load->library('email',$config);
}
我有Codeigniter邮件类的工作,我有未定义的变量错误。
function index()
{
$this->load->library('email',$config);
}
我有Codeigniter邮件类的工作,我有未定义的变量错误。
干草jems我只是删除$ config变量,因为它会自动加载。
感谢大家 – 2013-04-23 11:17:37
$config
从来没有得到一个值,至少不是在你的代码是在范围之内。
你必须做
$config = 'foo';
或类似的东西,冥冥中的范围内,以初始化它。
您还应该使用
if(isset($config))
,以确保它确实存在。
或者仅使用ternary operator:
$config = isset($config) ? $config : 'default';
如果配置被ineed定义别的地方,那么你应该把它作为参数传入的功能。
index($config);
的笨库加载语法
你必须尝试加载邮件类:如果你想配置的加载时间的邮件类
$this->load->library('email');
那么语法是:
$this->load->library('email');
// config is
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
也试试这个:
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$this->load->library('email',$config);
然后'$ config'在哪里? – egig 2013-04-23 11:08:49
'$ config'在该范围内似乎不存在... – Jon 2013-04-23 11:09:13
$ config中是否有任何值? – Shin 2013-04-23 11:13:02