Is it possible to override a default PHP function?

I would like to override the _() PHP function so that it supports one or more arguments. Is it possible to do that using PHP code?


  • It is possible, using the Runkit extension.

    However, it's generally not considered a good idea, except for use with things like unit testing, where you may want to isolate some of your functionality.

    For general use, you shouldn't be overriding built-in functions because it makes your code harder to maintain, and opens you up to some very hard to debug issues.

    Also, the Runkit extension is marked as 'experimental', which means it really shouldn't be used in a production system.