Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php codeigniter正在本地服务器上工作,但:语法错误,意外';[';,在模型中预期为';'_Php_Codeigniter - Fatal编程技术网

Php codeigniter正在本地服务器上工作,但:语法错误,意外';[';,在模型中预期为';'

Php codeigniter正在本地服务器上工作,但:语法错误,意外';[';,在模型中预期为';',php,codeigniter,Php,Codeigniter,我正试图将我的codeigniter网站上传到000webhost服务器上。但它给了我一个语法错误 语法错误,中出现意外的“[”,应为“') /home/a4703701/public_html/application/controllers/update.php 但它在本地主机上工作正常 错误在模型中我的模型是 public function user($id=NULL) { if($id=='') { $q = $this-&

我正试图将我的codeigniter网站上传到000webhost服务器上。但它给了我一个语法错误

语法错误,中出现意外的“[”,应为“') /home/a4703701/public_html/application/controllers/update.php

但它在本地主机上工作正常

错误在模型中我的模型是

public function user($id=NULL)
    {
       if($id=='')
         {
            $q  = $this->db->get('user');
            if($q->num_rows()>0)
            {
                return $q;
            }
         }
      else 
         {
            $q  = $this->db->get_where('user',['id'=>$id]);
            if($q->num_rows()>0)
            {
                return $q->row();
            }
         }
    }

您知道如何删除此错误吗?

您几乎肯定没有运行PHP 5.4或更高版本,而是尝试使用仅在这些版本中可用的语法

['id'=>$id]
是速记数组语法,在PHP 5.4中引入。您需要将其替换为:

array('id'=>$id)

与以前的PHP版本向后兼容。

您几乎肯定没有运行PHP5.4或更高版本,而是尝试使用仅在这些版本中可用的语法

['id'=>$id]
是速记数组语法,在PHP 5.4中引入。您需要将其替换为:

array('id'=>$id)

与以前的PHP版本向后兼容。

['id'=>$id]
替换为
数组('id'=>$id)
。第一种方法是在Javascript和PHP5.4+(?)中创建数组,而后者是在PHP中创建数组的正确方法。将
['id'=>$id]
替换为
数组('id'=>$id>)
。第一种是用Javascript和PHP5.4+(?)创建数组的方法,而第二种是用PHP创建数组的正确方法。
['id'=>$id]