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

Relaxed Syntax With Const

<?php

class x {
    const array = [];
    const int   = 2;
}

print_r(x::array);
echo x::int;
echo x::class;

?>

Relaxed syntax is the possibility to use PHP keywords as method or class constant names. This leads to funny expressions, that look like something else.

The only forbidden keyword is class, as it is used to report the name of the current class.

See Also

PHP Features

Last updated: 10 September 2026