note 102698 deleted from function.eval by googleguy
| From: | googleguy@php.net | Date: | Fri, 24 Feb 2017 21:12:28 +0000 |
| Subject: | note 102698 deleted from function.eval by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208827@lists.php.net to get a copy of this message | ||
Note Submitter: Mark Simon
----
I have looked for a simple way of forcing PHP to interpolate strings after the event (that is, after
they have already been assigned, say from a text file).
The following seems to work:
<?php
$text='$a + $b = $c';
$a=2; $b=3; $c=$a+$b;
print eval("return<<<END\n$text\nEND;\n");
?>
I have even tried it with some potentially evil code, but the context seems to preclude interpreting
it as anything other than a string.
Mark