Include constant in string without concatenating

Is there a way in PHP to include a constant in a string without concatenating?

define('MY_CONSTANT', 42);

echo "This is my constant: MY_CONSTANT";


  • No.

    With Strings, there is no way for PHP to tell string data apart from constant identifiers. This goes for any of the string formats in PHP, including heredoc.

    constant() is an alternative way to get hold of a constant, but a function call can't be put into a string without concatenation either.

    Manual on constants in PHP