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

Const Without Parenthesis

<?php

const A = 1;
echo ( A ) + (3);

const int = 2;
echo ( int ); // syntax error!!

It is possible to put a single literal inside parenthesis: that’s just the literal itself.

It is possible to put a single global constant inside parenthesis: that’s just the global constant itself.

It is possible to create a constant called int, because the name is not protected against usage, even if it is reserved for type and casting.

Then, it is not possible to int in parenthesis, because PHP confuses it with a cast.

See Also

PHP Features

Last updated: 09 November 2026