note 49020 added to function.eval

From: Date: Fri, 14 Jan 2005 15:46:13 +0000
Subject: note 49020 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-83270@lists.php.net to get a copy of this message
function StrToInSide($FStr,$EStr,$Str) // Fast 0.00/s preg_match is 0.0/s this 40000 Lines 1.6MB { $SPos = strpos($Str,$FStr); $EPos = strpos($Str,$EStr); if((!empty($SPos)) and (!empty($EPos))) { $EPos = ($End-$SPos)+strlen($EStr); return substr($Str,$SPos,$EPos); } else return null; } function Eval_Str($Contents) //Fast 100 PHP SCRIPT 0.017423/s Size 1MB 30,000 Lines { $Matches=UStrToInSide('<?','?>',$Contents); while(!empty($Matches)) { $Matches_Str=eregi_replace('(<\?|\?>)','', $Matches_Str); ob_start(); @eval($Matches_Str); $Eval_Str = ob_get_contents(); ob_end_clean(); $Contents = str_replace($Matches,$Eval_Str,$Contents); Matches=UStrToInSide('<?','?>',$Contents); } return $Contents; } Sample contents.html <table> <tr> <td> <? echo 'Hello'; ?> </td> </tr> </table> Eval_Str.php $Contents=implode('',file('contents.html')); echo Eval_Str($Contents); Output <table> <tr> <td> Hello </td> </tr> </table> ---- Manual Page -- http://www.php.net/manual/en/function.eval.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49020 Delete -- http://master.php.net/manage/user-notes.php?action=delete+49020&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49020&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+49020&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+49020&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+49020&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+49020&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+49020&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#83270) next »