【问题标题】:CodeIgniter Error using Memcached inside cURL在 cURL 中使用 Memcached 的 CodeIgniter 错误
【发布时间】:2014-05-12 12:32:17
【问题描述】:

尝试在 Codeigniter 内的 cURl 写入函数中使用 memcached 时出现错误。

curl_setopt($ch, CURLOPT_WRITEFUNCTION, function($ch, $str)
                                        {                                                       //print(htmlentities($str)."\n\n");
$ci &= get_instance();
$ci->cache->memcached->save('foo', 'bar', 600);                                              return strlen($str);
});

错误是

Message: Undefined variable: ci

Message: Object of class admin_test could not be converted to int

有什么建议吗?

我尝试了来自此链接CodeIgniter: can't access $this within function in view 的建议 从这里开始: Object of class stdClass could not be converted to string

我可以使用 $ci 语法来进行这样的数据库查询

$ci->db->query('SELECT * FROM TABLE');

但不是使用 memcached。

【问题讨论】:

    标签: php codeigniter curl memcached


    【解决方案1】:

    我想通了,并没有我想象的那么难。

    我正在使用

    $ci &= get_instance();
    

    但我需要的是

    $ci = get_instance();
    

    【讨论】:

      猜你喜欢
      • 2012-01-07
      • 1970-01-01
      • 1970-01-01
      • 2018-01-20
      • 2011-02-06
      • 2020-04-09
      • 2016-10-08
      • 1970-01-01
      • 2012-06-09
      相关资源
      最近更新 更多