Problem with EVAL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lagon666
    New Member
    • Jun 2009
    • 22

    Problem with EVAL

    Hi
    I have a code that when i use it, it crashes. May you suggest a solution for this code EXCEPT replaceing(characters such as quotation, double quotation, slash and back slash) and decoding the input?

    Code:
    $input = 'inputs " text';
    $output = eval('$text = "'.$input.'"; return $text;')
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    You need to escape that double quote in your $input variable. Otherwise, PHP sees it as the closing quote to your string in eval(). After that, there's an extra double quote which causes PHP to complain.

    Code:
    $input = 'inputs \" text';
    $output = eval('$text = "'.$input.'"; return $text;');

    Comment

    Working...