Reputation: 391
I would like to execute a string as if it were PHP code.
An example would be:
$string='round(24.6,2)';
I would like to convert $string
to executable syntax. Is there a way to do this?
Upvotes: 0
Views: 1035
Reputation: 7953
You can use eval('round(24.6,2)')
, but this is usually frowned upon for multiple reasons. Why do you want to do this?
Upvotes: 2