I would like to define a class named "List" like this:
class List
{
}
PHP gives the following error at the file of the class definition: "Parse error: 开发者_如何学Csyntax error, unexpected T_LIST, expecting T_STRING"
Apparently there is a php built-in function named "list()" that the parser is reading here instead of my class definition even though the line starts with the keyword class
Since I don't use the built-in function anywhere in my project I would like to "remove/disable" it, so I can use my class named "List".
Is this possible in php and how?
list
is a reserved word as it is a language construct (not actually a function), so no, you cannot disable it. Try being more specific with your class name, e.g., ObjectList
or AbstractList
.
The class name can be any valid label which is a not a PHP reserved word.
List of PHP reserved words says list
is one of those words.
精彩评论