控制器(php)错误。这是什么意思?

时间:2015-01-31 18:44:58

标签: php codeigniter error-handling

我在mvc framework article中有一个名为codeigniter的控制器。

在我上传到主机之前,此控制器没有错误。

这是错误:

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 个答案:

答案 0 :(得分:2)

请改用此代码。如果您使用CI版本低于3.0

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

如果CI大于或等于3.0,则

if ( $this->input->post("mysubmit") !== NULL ) {
相关问题