shevado shevado - 1 year ago 81
PHP Question

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

I am using Codeigniter 3.0.6. And i am developing on my local server and my php version is already php7. It works well. But then i uploaded it on server that use php 5.6. Then i got this error.

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


Here's my controller

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

class Student extends CI_Controller {

public function __construct()
$this->cname = 'student';
$this->menu = 'Student';
$this->fitur = '';
flash_err('Authorization needed.');
flash_err("You don't have privilege to use `{$this->menu}` feature.");

public function index()

public function action($func='', $id=0)
else if(empty($id))
flash_err("You don't have permission.");

public function list()
$this->fitur = 'List';

It just occured to me that list isnt allowed to be a method name. I wonder why it runs on php7 though.

Answer Source

This is due to the fact that list is a reserved keyword for PHP. Prior to PHP 7, you could not use these as method names.

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download