Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    42
    Thanks
    11
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    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.

  • Users who have thanked aedrin for this post:

    frozenade (01-11-2008)

  • #3
    New Coder
    Join Date
    Jun 2007
    Posts
    42
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Thumbs up

    oh i understand now.

    thank you very much,


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •