【问题标题】:Getting errors in Codeigniter after moving application移动应用程序后在 Codeigniter 中出现错误
【发布时间】:2013-10-02 08:09:30
【问题描述】:
                    if ($query1->num_rows() > 0){
                        log_message('debug', 'Cert Found');
                        $result[$i]->cert = $query1->result()[0]->door_resource_url;
                    } else {
                        log_message('debug', 'Cert Not Found');
                        $result[$i]->cert = "no";
                    }

这个$query1->result()[0] 是引发错误的原因,但我不明白为什么,因为它在我移动主机之前有效,现在我似乎无法解决这个问题。

有人知道我做错了什么吗?

【问题讨论】:

  • 我明白了,我认为这是 PHP 版本的不同。
  • $result[$i]->cert = $query1->row(1)->door_resource_url;
  • 每当您报告您在应用程序中遇到错误时,,每次都说明它们是什么。

标签: php arrays codeigniter object


【解决方案1】:

是的,当添加function dereferencing 时,您主机的 php 版本可能是

添加了函数数组解引用,例如foo()[0].

所以你不能这样做 $query1->result()[0] 但你需要将它分配给一个变量并在那里引用它:

$temp = $query1->result();
$result[$i]->cert = $temp[0]->door_resource_url;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-18
    • 1970-01-01
    • 2013-08-05
    • 2022-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-27
    相关资源
    最近更新 更多