I need to fetch a constant value. The constant name is stored in a variable.
<?php
define('SomeConstant', 12345);
$variable = 'SomeConstant';
?>
How would I echo "12345" using the variable?
Use the constant function
echo constant($variable);
<?php
define('SomeConstant', 12345);
$variable = SomeConstant;
echo $variable;
?>
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