class List { public function hello() { return "hello"; } } $list = new List; echo $list::hello();
给出错误:
PHP Parse error: Syntax error,unexpected 'List' (T_LIST),expecting identifier (T_STRING) in /home/WtGTRQ/prog.PHP on line 3
将“List”更改为“Lizt”可以解决问题.
我遗憾地理解Php functions are case-insensitive,但我真的不想让List对象成为一个Lizt对象…有没有办法绕过这个而不重命名我的类?