dongyi1982 2014-04-01 15:54 采纳率: 0%
浏览 28
已采纳

在cURL中使用Memcached的CodeIgniter错误

I'm getting an error when trying to use memcached inside a cURl write function inside Codeigniter.

curl_setopt($ch, CURLOPT_WRITEFUNCTION, function($ch, $str)
                                        {                                                       //print(htmlentities($str)."

");
$ci &= get_instance();
$ci->cache->memcached->save('foo', 'bar', 600);                                              return strlen($str);
});

The errors are

Message: Undefined variable: ci

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

Any suggestions?

I tried the advice from this link CodeIgniter: can't access $this within function in view and from here: Object of class stdClass could not be converted to string

I can use the $ci syntax to make a database query like this

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

but not with memcached.

  • 写回答

1条回答 默认 最新

  • dpauf28808 2014-04-01 16:17
    关注

    I figured it out, not nearly as hard as I thought.

    I was using

    $ci &= get_instance();
    

    But what I needed was

    $ci = get_instance();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化