Class And Constant Confusion¶
<?php
const stdClass = 1;
new stdClass;
?>
Class names and global constant names are two distinct name spaces. It is possible to use the name of a class as a constant.
It is also possible to instantiate a class with a constant notation: that is, by omitting the parenthesis in the new call, when no arguments are needed.
This allows for very confusing lines like these ones.
See Also¶
PHP Features¶
Last updated: 14 July 2026