CI 3 的方法不适用于 php 5.6 版本,但适用于 php 7

Method of CI 3 doesn't work on php 5.6 version but works on php 7

我正在使用 Codeigniter 3.0.6。我正在本地服务器上开发,我的 php 版本已经是 php7。它运作良好。但后来我将它上传到使用 php 5.6 的服务器上。然后我得到了这个错误。

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);
    }
}

啊啊啊啊 我刚刚想到 list 不允许作为方法名称。我想知道为什么它会在 php7 上运行。

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

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

As of PHP 7.0.0 these keywords are allowed as as property, constant, and method names of classes, interfaces and traits, except that class may not be used as constant name.

原来列表不允许作为方法名。我更改了方法名称,现在效果很好。虽然我仍然想知道为什么它在 php7 上运行良好。