Access overwritten built-in functions in PHP

PHP has many built in functions. Normally you can’t override them. The only exception: If you’re in another namespace. But how can you then access the real function again? Simply add a backslash before the functions name and the built-in function get called.


    namespace test{
        function phpversion(){
            return "Not the real phpversion";
        echo phpversion()."<br />";
        echo \phpversion()."<br />";
        echo phpversion()."<br />";

This will output something like:

Not the real phpversion 8.0.0 Not the real phpversion

Written on March 1, 2022