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...
No, you cannot redefine a constant (except with runkit_constant_redefine), that's why is called CONSTANT. Short answer: No.
Use the define() function to create a constant. It defines constant at run time. Let's see the syntax of define() function in PHP.
In PHP, the constant is an identifier or a name for a simple value. The constant value can't be changed during script execution. In PHP, the variable is a name or symbol which stands for value and used to store values such as characters, numeric, character string and memory addresses.
Check out constant()
.
In your case:
echo constant($stuff . '_FOO');
First make a constant:
define("FOO_BAR", "something more");
then you can get the value by using constant()
:
echo constant("FOO_BAR");
Read more about constants in the manual.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With