Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to make a CodeIgniter controller called "List"

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

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

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

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

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?

Thanks,
Mala

like image 846
Mala Avatar asked Jan 06 '10 16:01

Mala


2 Answers

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.

like image 168
davethegr8 Avatar answered Nov 14 '22 21:11

davethegr8


list is a built-in php construct

like image 22
jspcal Avatar answered Nov 14 '22 22:11

jspcal