如何在字符串中计算常量? [重复]

Possible Duplicate:
Include constant in string without concatenating

How can I get a constant to be evaluated in a string like variables are?

$foo = "like";
define('BAR', 'fish');

// None of these give me 'I like to eat fish on Tuesday.'
echo "I $foo to eat BAR on Tuesday.";
echo "I $foo to eat {BAR} on Tuesday.";
echo 'I $foo to eat BAR on Tuesday.';

// This works but is undesirable
echo 'I $foo to eat '.BAR.' on Tuesday.';

As far as I know that isn't possibile. Check this answer here at SO, it contains useful workarounds if concatenation is so undesirable too you! Include constant in string without concatenating

of course there is no way. And no need.

The only way I know this'd works (which you may already be aware of) is by doing:

<?php
$foo = "like";
define('BAR', 'fish');
$constants = get_defined_constants();
echo "I $foo to eat {$constants['BAR']} on Tuesday.";
?>

which prints:

I like to eat fish on Tuesday.