Alex Alex - 5 months ago 11
PHP Question

PHP: echoing a constant with a variable name

How can I do that?

I have something like:

define($stuff.'_FOO', 'whatever');
echo $stuff.'_FOO';


and it doesn't work :(

I just want to echo the constant's value...

Answer

Check out constant().

In your case:

echo constant($stuff . '_FOO');