I need to find all occurrences of any PHP-related code found in a string of text. If PHP is found it must be evaluated.
This is what I have so far:
// NEW 8/4/2005: IF PHP CODE WAS EMBEDDED, DO AN EVALUATION
foreach (array('string_1', 'string_2') as $string) if (preg_match('/^.*<\?(php)?.+\?' . '>.*$/i', preg_replace('/[\n\r]+/i', "\s", ${$string}))) ${$string} = eval(${$string});
The string text could be pure PHP, HTML with embedded PHP, pure HTML, or even plain text. It will be ASCII of some kind but you have no way of knowing if PHP is found inside the strings or not.
The following lines of code produce this error:
<b>Parse error</b>: parse error in <b>/page.php(69) : eval()'d code</b> on line <b>1</b><br>
Has anyone ever had to do something like this before, if so, what have you done?
Thanx
Phil