2015-01-31 23 views
-2

我在mvc框架codeigniter中有一個名爲article的控制器。控制器(php)錯誤。這是什麼意思?

直到我上傳到主機,這個控制器沒有錯誤。

這是錯誤:

Fatal error: Can't use method return value in write context in /home/focusweb/public_html/cms/application/controllers/administrator/article.php on line 17

而且我的控制器:(有符合17一個問題,但它在localhost作品)

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 

class Article extends CI_Controller { 

public function index() { 
    $this->home(); 
} 
public function home() { 

    if($this->session->userdata('is_logged_in')){ 
     $this->load->view("site_header"); 
     $this->load->model("db_login"); 
     $data['first_name'] = $this->db_login->get_name($user_id); 
     $this->load->view("site_nav", $data); 
     $user_id = $this->session->userdata('uid'); 
     $data['name'] = ""; 
     if(isset($this->input->post("mysubmit"))){ 
      $data['name'] = $this->input->post("name"); 
      $data['content'] = $this->input->post("content"); 
     } 


     $this->load->model("db_new_category");   
     //get hierarchal data from database 
     $get_all_category = $this->db_new_category->get_all_category(); 
     //manage hierarchal data and send them to view 
     $this->load->model("hierarchy"); 

     $this->load->model("db_new_category");   
     $get_all_category = $this->db_new_category->get_all_category(); 
     $this->load->model("hierarchy"); 
     $data1 = $this->hierarchy->get_hierarchy($get_all_category, 'category_name_db', 'deep', 'id', 'count'); 
     $data = $data + $data1; 
     $this->load->view("add_article", $data1); 
     $this->load->view("site_footer"); 
    } 
    else redirect('administrator/login'); 
} 

第17行是在這裏:

if(isset($this->input->post("mysubmit"))){ 
+1

請這裏的代碼複製粘貼文本,而不是作爲一個屏幕截圖。 – JJJ 2015-01-31 18:46:34

+0

@Juhana完成:) – 2015-01-31 18:56:59

+0

[參考 - 這個錯誤在PHP中意味着什麼?](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php ) – deceze 2015-02-01 11:25:54

回答

2

使用此公司代替。如果你使用CI版本低於3.0

if ($this->input->post("mysubmit") !== false) { 

如果CI大於或等於3.0,然後

if ($this->input->post("mysubmit") !== NULL) { 
+0

謝謝。不僅是你的代碼,而且當我定義'$ this-> input-> post('mysubmit')'作爲一個變量並且將它用於'if'時它可以工作。順便說一句,非常感謝:) – 2015-01-31 19:17:32