试图使一个叫做“List”的CodeIgniter控制器 [英] Trying to make a CodeIgniter controller called "List"

查看:203
本文介绍了试图使一个叫做“List”的CodeIgniter控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在controllers / list.php中有以下代码:

I have the following code in controllers/list.php:

<?php
class List extends Controller { 
    function index()
    {
        echo "hi";
    }
}
?>

但是,尝试访问它会给我以下PHP错误:

However, trying to access it gives me the following PHP error:

分析错误:语法错误,意外的T_LIST,期望在 /var/www/sitename/htdocs/system/application/controllers/list.php 在线 3

Parse error: syntax error, unexpected T_LIST, expecting T_STRING in /var/www/sitename/htdocs/system/application/controllers/list.php on line 3

将文件重命名为example.php,将class List替换为class Example我的第一个想法是可能列表是保留名称,但我检查了CI的保留名称列表这里,它不存在。

Renaming the file to "example.php" and replacing "class List" with "class Example" works perfectly fine... my first thought was maybe "List" was a reserved name, but I checked CI's list of reserved names here and it's not there.

我知道我可以解决这个问题,只是调用的东西别的东西,但我真的想要我的控制器被称为列表如果可能的话。

I know I could fix the problem by just calling the thing something else but I really want my controller to be called "list" if at all possible. Any ideas, or insight into why this is happening?

感谢,

Mala

Thanks,
Mala

推荐答案

list 是PHP中的保留字,所以你必须使用别的东西。如果您真的需要,您可以使用自定义路线更改网址。

list is a reserved word in PHP, so you'll have to use something else. You can probably use a custom route to change the url if you really need to.

这篇关于试图使一个叫做“List”的CodeIgniter控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆