【问题标题】:Why does my PHP error controller work with PHP 5, but not PHP 7?为什么我的 PHP 错误控制器适用于 PHP 5,而不适用于 PHP 7?
【发布时间】:2019-06-22 04:23:39
【问题描述】:

我正在将我的项目从 PHP 5 迁移到 PHP 7.3,我已经使用替代函数对解密函数进行了更改。但是我面临一个控制器文件的问题。

相同的代码适用于 PHP5 版本,但是当我尝试为 PHP 7 执行相同的代码时,即使没有在 errorLog 文件中添加错误,它也不会给出任何错误。你能帮我解决这个问题吗?

我正在上传我的“error.php”控制器文件。

<?php
class Error extends CI_Controller {    
      private $controller = "error";      
      public function __construct() {
      parent::__construct();
      if ($this->phpsession->get('USERID')) {
          $headerContent['controller'] = $this->controller;
          $this->load->view('xome/header', $headerContent);
      } else {
          header("Location:" . ASITEURL . "/login/");
      }
    }

    public function index() {
      $this->load->view('x-404');
      $this->load->view('xome/footer');
    }

    public function permission() {
      $this->load->view('x-permission');
      $this->load->view('xome/footer');
    }

    public function display() {
      $this->load->view('x-error');
      $this->load->view('xome/footer');
    }
}
?>

当我点击 URL 时,它应该会加载视图页面,但无法加载任何视图文件。

http://localhost/--project文件夹名称--/错误/权限

即使我检查了控制器以及任何视图文件中都没有语法错误。

【问题讨论】:

    标签: php codeigniter-2 php-7 php-7.3


    【解决方案1】:

    从 PHP7 开始,Error 是保留的类名:http://php.net/manual/en/class.error.php

    把它改成别的东西:

    class MyError extends CI_Controller 
    {
       // ....
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-19
      • 2018-02-20
      • 2017-12-09
      相关资源
      最近更新 更多