note 45323 added to function.eval
| From: | michael at smartgrp dot net | Date: | Thu, 02 Sep 2004 02:16:46 +0000 |
| Subject: | note 45323 added to function.eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-75919@lists.php.net to get a copy of this message | ||
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;
?>
----
Manual Page -- http://www.php.net/manual/en/function.eval.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45323
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45323&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45323&report=yes
Search -- http://master.php.net/manage/user-notes.php