Can I use string concatenation to define a class CONST in PHP?

The only way is to define() an expression and then use that constant in the class

define('foobar', 'foo' . 'bar');

class Foo
{
    const blah = foobar;
}

echo Foo::blah;

Another option is to go to bugs.php.net and kindly ask them to fix this.

Leave a Comment