mixed Is Now A Keyword¶
mixed was introduced in PHP 8.0 as a new type. As a side effect, it is now a PHP keyword, and it is not possible to create classes, functions or constants with that name.
PHP code¶
<?php
class mixed {
function __construct() {
echo __METHOD__;
}
}
new mixed;
?>
Before¶
mixed::__construct
After¶
PHP Fatal error: Cannot use 'mixed' as class name as it is reserved in /codes/mixedKeyword.php on line 3
Fatal error: Cannot use 'mixed' as class name as it is reserved in /codes/mixedKeyword.php on line 3
PHP version change¶
This behavior changed in 8.0