note 102698 added to function.eval

[email protected] Tue, 1 Mar 2011 03:29:11 -0800
Newsgroups php.notes
Message-ID <[email protected]>
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
----
Server IP: 117.104.162.229
Probable Submitter: 27.32.215.64 (proxied: 27.32.215.64)
----
Manual Page -- http://www.php.net/manual/en/function.eval.php
Edit        -- https://master.php.net/note/edit/102698
Del: integrated  -- https://master.php.net/note/delete/102698/integrated
Del: useless     -- https://master.php.net/note/delete/102698/useless
Del: bad code    -- https://master.php.net/note/delete/102698/bad+code
Del: spam        -- https://master.php.net/note/delete/102698/spam
Del: non-english -- https://master.php.net/note/delete/102698/non-english
Del: in docs     -- https://master.php.net/note/delete/102698/in+docs
Del: other reasons-- https://master.php.net/note/delete/102698
Reject      -- https://master.php.net/note/reject/102698
Search      -- https://master.php.net/manage/user-notes.php