Trying to create a CodeIgniter controller called List

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

<?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, waiting for 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 fine ... my first thought was maybe "List" was a reserved name, but I checked the list of reserved CI names here , and that not there.

I know that I can fix this problem by simply calling something else, but I really want my controller to be called a "list", if at all possible. Any ideas or insights on why this is happening?

Thanks,
Mala

+6
php codeigniter controller reserved-words
source share
2 answers

list is a reserved word in PHP, so you have to use something else. Perhaps you can use your own route to change the URL if you really need to.

+14
source share

list is an inline php construct

+1
source share

All Articles