Redefine Native Functions

<?php

echo strtolower('ABC').PHP_EOL;

function b($a) {
    print "b: $a
";
}

use function b as strtolower;

echo strtolower('ABC').PHP_EOL;

It is possible to redefine PHP functions or constants, or even any defined of such, by using the use command.

This feature is interesting for testing purposes: it allows the replacement of a defined function with an alternative.

It is not possible to do this twice in the same file, nor to redefine classes.

See Also

PHP Features

Last updated: 14 July 2026