Execute a string in PHP?
Posted: Sat Jul 24, 2004 10:39 pm
Here is my situation. I have some variables in a php program:
$foo1 = "stuff";
$foo2 = "more stuff";
...
$foo50 = "end of stuff";
What I would like to know is if there is a command in PHP to instruct PHP to execute a given string in PHP. So in other words,
<?
$i = 0;
while ($i < 50) {
execute_command("echo $foo" . $i);
i++;
}
?>
..would cause php to execute the commands "echo $foo1", "echo $foo2", etc... The end result of the program would then be:
stuff
more stuff
...
end of stuff.
My question is: Is there a command like "execute_command" (this was just a name I made up) that will do what I've described?
Hope this makes sense...
$foo1 = "stuff";
$foo2 = "more stuff";
...
$foo50 = "end of stuff";
What I would like to know is if there is a command in PHP to instruct PHP to execute a given string in PHP. So in other words,
<?
$i = 0;
while ($i < 50) {
execute_command("echo $foo" . $i);
i++;
}
?>
..would cause php to execute the commands "echo $foo1", "echo $foo2", etc... The end result of the program would then be:
stuff
more stuff
...
end of stuff.
My question is: Is there a command like "execute_command" (this was just a name I made up) that will do what I've described?
Hope this makes sense...