Is it possible to “escape” a method name in PHP, to be able to have a method name that clashes with a reserved keyword?

后端 未结 2 1981
难免孤独
难免孤独 2021-01-19 21:48

I\'m doing MVC in PHP, and i\'d like to have a list() method inside my Controller, to have the URL /entity/list/parent_id, to show all the \"x\" that belong to that parent.<

2条回答
  •  执念已碎
    2021-01-19 22:01

    With variable names you can use the bracket signs:

    ${'array'} = "test";
    echo ${'array'};
    

    But PHP does not provide a method for escaping function names.

    If you want a 'user-defined' way of getting around this, check out this comment:

    http://www.php.net/manual/en/reserved.keywords.php#93368

提交回复
热议问题