note 45323 deleted from function.eval by sniper
| From: | sniper@php.net | Date: | Thu, 29 Dec 2005 09:15:21 +0000 |
| Subject: | note 45323 deleted from function.eval by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-100909@lists.php.net to get a copy of this message | ||
Note Submitter: michael at smartgrp dot net
----
After several hours of reviewing examples I believe I've come up with a decent method of
dynamically loading php pages. I hope this helps, and if anyone else has any better ideas, please
post them.
<?php
$eval_str = // Your Web Page Source Code....
preg_match_all("/(<\?php|<\?)(.*?)\?>/si", $eval_str,
$raw_php_matches);
$php_idx = 0;
while (isset($raw_php_matches[0][$php_idx]))
{
$raw_php_str = $raw_php_matches[0][$php_idx];
$raw_php_str = str_replace("<?php", "", $raw_php_str);
$raw_php_str = str_replace("?>", "", $raw_php_str);
ob_start();
eval("$raw_php_str;");
$exec_php_str = ob_get_contents();
ob_end_clean();
$eval_str = preg_replace("/(<\?php|<\?)(.*?)\?>/si",
$exec_php_str, $eval_str, 1);
$php_idx++;
}
return $eval_str;
?>