note 90897 added to function.eval
| From: | chrisdone at gmail dot com | Date: | Fri, 15 May 2009 07:25:17 +0000 |
| Subject: | note 90897 added to function.eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-154626@lists.php.net to get a copy of this message | ||
You can use it to embed arbitrary embeded languages or "macros":
<?php
$id = 10;
// SQL
ob_start(); ?>
SELECT * FROM users WHERE parentid > $id
AND name LIKE '%s%'
<?php $f=ob_get_contents();ob_end_clean();$sql=eval('return ("'
.$f.'");');
echo $sql;
?>
Outputs:
SELECT * FROM users WHERE parentid > 10 AND name LIKE '%s%'
----
Server IP: 209.41.74.194
Probable Submitter: 82.33.137.16
----
Manual Page -- http://www.php.net/manual/en/function.eval.php
Edit -- https://master.php.net/note/edit/90897
Del: integrated -- https://master.php.net/note/delete/90897/integrated
Del: useless -- https://master.php.net/note/delete/90897/useless
Del: bad code -- https://master.php.net/note/delete/90897/bad+code
Del: spam -- https://master.php.net/note/delete/90897/spam
Del: non-english -- https://master.php.net/note/delete/90897/non-english
Del: in docs -- https://master.php.net/note/delete/90897/in+docs
Del: other reasons-- https://master.php.net/note/delete/90897
Reject -- https://master.php.net/note/reject/90897
Search -- https://master.php.net/manage/user-notes.php