I need your help to solve a problem I’ve bumped into.
The best way to explain it is with a simple example (how bad sounds this!!), better than to put much more complex code:
[code=php]<?php
define(“myConstant1”, 3);
define(“myConstant2”, 5);
define(“myConstant3”, 7);
define(“myConstant4”, 9);
echo “<p>My Constants: “.myConstant1.”, “.myConstant2.”, “.myConstant3.”, “.myConstant4.”</p>”;
$constants_list = array(‘myConstant1’, ‘myConstant2’, ‘myConstant3’, ‘myConstant4’);
echo “<p>My Constants: “;
for ($i=0; $i < 4; $i++) {
echo $constants_list[$i].” “;
}
echo “</p>”;
?>
The “for” loop outputs the name of the constants, and what I want is to output their value. How could I do this? I tried with eval() but I got an error syntax.
Any help please?