2016-06-21 121 views
2

我正在使用Codeigniter 3.0.6。我正在开发我的本地服务器,我的PHP版本已经是php7。它运作良好。但后来我上传到使用PHP 5.6的服务器上。然后我得到这个错误。CI 3的方法不适用于PHP 5.6版本,但适用于PHP 7

Parse error: syntax error, unexpected 'list' (T_LIST), expecting identifier (T_STRING) in /var/www/simimi/application/controllers/Student.php on line 53 
A PHP Error was encountered 

    Severity: Parsing Error 

    Message: syntax error, unexpected 'list' (T_LIST), expecting identifier (T_STRING) 

    Filename: controllers/Student.php 

    Line Number: 53 

    Backtrace: 

这里是我的控制器

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

class Student extends CI_Controller { 

    public function __construct() 
    { 
     parent::__construct(); 
     $this->load->model('m_student','sdb'); 
     $this->load->model('m_student_profile','sdb_pro'); 
     $this->load->model('m_student_academic','sdb_aca'); 
     $this->load->model('m_student_immigration','sdb_imm'); 
     $this->load->model('m_student_emergency','sdb_eme'); 
     $this->cname = 'student'; 
     $this->menu = 'Student'; 
     $this->fitur = ''; 
     $this->active_user=get_nama_user(); 
     $this->active_username=get_username(); 
     $this->active_privilege=get_hak_akses(); 
     if(!cek_auth()) 
     { 
      flash_err('Authorization needed.'); 
      redirect(base_url('auth')); 
     } 
     if(!cek_fitur('student_list')) 
     { 
      flash_err("You don't have privilege to use `{$this->menu}` feature."); 
      redirect(base_url('dashboard')); 
     } 
    } 

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

    public function action($func='', $id=0) 
    { 
     if(!empty(trim($func))) 
     { 
      if(!empty($id)) 
       $this->$func($id); 
      else if(empty($id)) 
       $this->$func(); 
     } 
     else 
     { 
      flash_err("You don't have permission."); 
      redirect(base_url($this->cname)); 
     } 
    } 

    public function list() 
    { 
     $data['title']='Student'; 
     $data['subtitle']='List'; 
     $data['active']='student_list'; 
     $this->fitur = 'List'; 
     $data['content']='student_list'; 
     $data['students']=$this->sdb->get_list(); 
     $this->load->view('template/template',$data); 
    } 
} 

Aaaaand 它只是发生在我允许是一个方法名列表的心不是。我想知道它为什么运行在php7上。

+0

/var/www/simimi/application/controllers/Student.php打开精美的外观@line 53. CAn请发布代码 –

+0

已经添加了@KARTHISRV但我认为我的控制器很好,因为我的程序运行良好在我的服务器上使用php7 – shevado

回答

2

这是因为list是PHP的保留关键字。在PHP 7之前,您不能将这些用作方法名称。

http://www.php.net/manual/en/reserved.keywords.php

由于PHP 7.0.0的这些关键字都可以作为财产,常量和方法的类,接口和特性的名字,但同类不得用作常量名。

+0

谢谢。我也意识到了这一点。我感到恐慌。 – shevado

0

结果列表不允许是方法名称。我改变了方法名称,现在它运行良好。虽然我仍然想知道为什么它在php7上运行良好。

相关问题