ci3法不';不适用于PHP5.6版本,但适用于PHP7
我正在使用Codeigniter 3.0.6。我正在本地服务器上开发,我的php版本已经是php7了。它工作得很好。但后来我把它上传到了使用PHP5.6的服务器上。然后我犯了这个错误 这是我的控制器ci3法不';不适用于PHP5.6版本,但适用于PHP7,php,codeigniter-3,Php,Codeigniter 3,我正在使用Codeigniter 3.0.6。我正在本地服务器上开发,我的php版本已经是php7了。它工作得很好。但后来我把它上传到了使用PHP5.6的服务器上。然后我犯了这个错误 这是我的控制器 <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Student extends CI_Controller { public function __construct()
<?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
是PHP的保留关键字。在PHP7之前,您不能将它们用作方法名
从PHP7.0.0开始,这些关键字可以作为类、接口和特征的属性名、常量名和方法名,但类不能用作常量名
结果是列表不允许是方法名。我更改了方法名,现在效果很好。尽管我仍然想知道为什么它在php7上工作得很好 /var/www/simimi/application/controllers/Student.php打开fine look@line 53。你可以发布代码吗?已经添加了@KARTHISRV,但我认为我的控制器很好,因为我的程序在使用PHP7的服务器上运行良好。谢谢。我也意识到了这一点。我很惊慌。
<?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);
}
}