...

View Full Version : which one would run faster?



frozenade
01-09-2008, 03:52 PM
Hello.

About these eval, which one would run faster ?


function wrapper($content) {
ob_start();
$content = str_replace('<'.'?php','<'.'?',$content);
eval('?'.'>'.trim($content).'<'.'?');
$content = ob_get_contents();
ob_end_clean();
return $content;
}

$content = file_get_contents('somefile.php');
$content = wrapper($content);
echo $content;


or


$content = file_get_contents('somefile.php');
$content = "?>" . $content;
eval($content);

I get confuse which one should I take in correct way.

aedrin
01-09-2008, 04:48 PM
This is the correct way (if you are trying to get the output of a PHP file):



ob_start();
include('somefile.php');
$output = ob_get_contents();
ob_end_clean();

echo $output;


Eval() is barely ever useful, and in most cases a security risk.

frozenade
01-11-2008, 11:02 AM
oh i understand now.

thank you very much, :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum