Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

class_alias() Works On Internal Classes

class_alias() makes an alias for a class, an enumeration, an interface or a trait. Until PHP 8.3, it was only possible on custom structures.

PHP code

<?php

class_alias(stdClass::class, A::class);

var_dump(new A);

?>

Before

First argument of class_alias() must be a name of user defined class

After

object(stdClass)#1 (0) {
}

PHP version change

This behavior changed in 8.3.

See Also

Error Messages

Extension

© 2023-2026, Damien Seguy - Exakat