I have a row in a mysql table whose column contains:
This is a test.
I have another row in the same mysql table whose same column contains:
K_IM_A_CONSTANT
Earlier on in the PHP script, this line of code exists:
define(K_IM_A_CONSTANT, 'This is a constant.');
How can I echo the contents of the column whereby, the returned value would either be "This is a test." or "This is a constant.", depending on the row selected?
Is eval() the way to do it? If so, how might the eval() syntax look? I have been getting too many errors trying to get eval() to work.
Thanks for helping.
Use the constant
function:
if(defined($row['column_name']))
{
echo constant($row['column_name']);
}
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