note 99366 added to function.preg-replace-callback
| From: | KyleK dot at osu1 dot php dot net | Date: | Fri, 13 Aug 2010 00:30:43 +0000 |
| Subject: | note 99366 added to function.preg-replace-callback | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171629@lists.php.net to get a copy of this message | ||
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);
----
Server IP: 208.69.120.55
Probable Submitter: 74.4.242.180
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace-callback.php
Edit -- https://master.php.net/note/edit/99366
Del: integrated -- https://master.php.net/note/delete/99366/integrated
Del: useless -- https://master.php.net/note/delete/99366/useless
Del: bad code -- https://master.php.net/note/delete/99366/bad+code
Del: spam -- https://master.php.net/note/delete/99366/spam
Del: non-english -- https://master.php.net/note/delete/99366/non-english
Del: in docs -- https://master.php.net/note/delete/99366/in+docs
Del: other reasons-- https://master.php.net/note/delete/99366
Reject -- https://master.php.net/note/reject/99366
Search -- https://master.php.net/manage/user-notes.php