note 99366 deleted from function.preg-replace-callback by danbrown
| From: | danbrown@php.net | Date: | Fri, 13 Aug 2010 00:43:01 +0000 |
| Subject: | note 99366 deleted from function.preg-replace-callback by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-171630@lists.php.net to get a copy of this message | ||
Note Submitter: Kyle K.
----
So, this is pretty much a big no no in PHP, but I have found a great use for it in a safe way.
Having Pseudo PHP. I work for a company that has a view called ... the way the logic is right now,
the view is called and parsed by PHP, then it has field replacments to replace stuff in the file
such as %MYVAR% ... well, we need to grab something at the same time that %MYVAR% is replace since
variables are now available, when before they were not. Here's the code:
$text = preg_replace_callback('/<!PHP(.*)!>/sU',
create_function('$matches','return eval($matches[1]);')
,$text);