在控制器的任何方法中添加注释后显示空白屏幕


Codeigniter - show blank screen after adding comment in any method of controller

Codeigniter在任何方法中添加注释后显示空白页面。在控制器索引方法中增加//redirect('home');。此外,不能从index.php

中启用错误报告。

但是在启用日志错误后,我在error_log文件

中得到这个错误
PHP Parse error:  syntax error, unexpected 'endif' (T_ENDIF) in /home/username/public_html/project/application/controllers/Home.php on line 1 

这里是控制器

<?php defined('BASEPATH') OR exit('No direct script access allowed');
    class Home extends CI_Controller {
        public function index(){
            echo 'Home Page';
            //redirect('home');
        }
        public function test(){
            echo 'Test';
        }

    }

花了几个小时后,我发现我的FTP客户端(FileZilla)出现了一些错误。

通过FileZilla上传文件时,如果有任何注释,它会将所有代码转换为一行,然后显示错误。

将第一行改为:

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