Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-09-2008, 03:52 PM   PM User | #1
frozenade
New Coder

 
Join Date: Jun 2007
Posts: 42
Thanks: 11
Thanked 0 Times in 0 Posts
frozenade is an unknown quantity at this point
Question which one would run faster?

Hello.

About these eval, which one would run faster ?

PHP Code:
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

PHP Code:
$content file_get_contents('somefile.php');
$content "?>" $content;
eval(
$content); 
I get confuse which one should I take in correct way.
frozenade is offline   Reply With Quote
Old 01-09-2008, 04:48 PM   PM User | #2
aedrin
Senior Coder

 
Join Date: Jan 2007
Posts: 1,648
Thanks: 1
Thanked 58 Times in 54 Posts
aedrin will become famous soon enough
This is the correct way (if you are trying to get the output of a PHP file):

PHP Code:
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.
aedrin is offline   Reply With Quote
Users who have thanked aedrin for this post:
frozenade (01-11-2008)
Old 01-11-2008, 11:02 AM   PM User | #3
frozenade
New Coder

 
Join Date: Jun 2007
Posts: 42
Thanks: 11
Thanked 0 Times in 0 Posts
frozenade is an unknown quantity at this point
Thumbs up

oh i understand now.

thank you very much,
frozenade is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:11 PM.


Advertisement
Log in to turn off these ads.