Is there a way to evaluate a constant inside double quotes to avoid concatenation using .
?
For example, I can do things like:
echo "$variable";
echo "{$array["index"]}";
echo "{$this->myProperty}";
Unfortunally echo "{MY_CONSTANT}" don't work.
So, is there a way to evaluate a constant like in the examples above, avoiding concatenation?
I know is there alternatives to code and get the same result, but I'm aiming at just the constants.
My motivation to this is to write sql statements, for example:
$sql = "SELECT * FROM {MY_JOIN} WHERE id > 100";
Where MY_JOIN
constant could be something like
"
orders
INNER JOIN
users
ON (orders.user_id = users.id)
"
or to avoid something like
$dir = DIRECTORY_SEPARATOR."folder1".DIRECTORY_SEPARATOR."folder2".DIRECTORY_SEPARATOR;
I know I can write something like $separator = DIRECTORY_SEPARATOR
and code
$dir = "{$separator}folder1{$separator}folder2{$separator}";
but if it is possible, I would like to do this with the constants directly.