Can I remove a php function?
I would like to use:
function list(args);
but li开发者_运维技巧st
is a reserved word.
Can I remove the list function from PHP, disable it, or otherwise?
No, you can't, nor should you want to. Redefining built-in functions is a Bad Thing, especially something as fundamental as list
, which isn't a function at all - it's a language construct.
All you can do is come up with a unique name for your function.
In a normal situation, no, you cannot remove a function.
Using the runkit extension (which I've virtually never seen installed on a server -- and absolutely never on a production server !), you'd have the runkit_function_remove()
function, that could help.
Same with other debugging extensions, such as APD, which provides the override_function()
, btw.
With PHP >= 5.3 and namespaces, you could also re-define a function, inside your own namespace, that could sort of replace the one of the global namespace.
But note that list()
is not a function : it is a language construct -- and, as such, it doesn't behave like functions...
As a sidenote : even if possible (and/or when possible), replacing an existing function with your own, that doesn't do the same thing, is not a good idea : people reading your code, maintaining it, will have more difficulties understanding what it does !
You can only rename/remove core functions using the runkit or APD extensions. list isn't actually a function, but a language construct, so you can't rename it even with those extensions.
You should really be using a better choice of names for your own functions... list() isn't particularly meaningful. list what?
精彩评论