PHXC8
V2EX  ›  PHP

Discuz 里面的 eval 有没有取代的办法?

  •  
  •   PHXC8 · Jul 4, 2015 · 3065 views
    This topic created in 3971 days ago, the information mentioned may be changed or developed.

    由于HHVM不支持eval(),一直没找到好的方法。求教,有什么办法代替,或者修改好的朋友求教!

    谢谢各位!

    例如:
    $template = preg_replace("/{{eval (.?)}}/ies", "\$this->stripvtag('<? \1?>')", $template);
    $template = preg_replace("/{eval (.
    ?)}/ies", "\$this->stripvtag('<? \1?>')", $template);

    RIcter
        1
    RIcter  
       Jul 4, 2015
    assert 也能执行代码(
    thankyourtender
        2
    thankyourtender  
       Jul 4, 2015
    hphpd>
    hphpd> $string = 'cup';
    $string = 'cup';
    hphpd> $name = 'coffee';
    $name = 'coffee';
    hphpd> $str = 'This is a $string with my $name in it.';
    $str = 'This is a $string with my $name in it.';
    hphpd> echo $str. "\n";
    echo $str. "\n";
    This is a $string with my $name in it.

    hphpd> echo $str. "\n";
    echo $str. "\n";
    This is a $string with my $name in it.

    hphpd> eval("\$str = \"$str\";");
    eval("\$str = \"$str\";");
    hphpd> eval("\$str = \"$str\";");
    eval("\$str = \"$str\";");
    hphpd> eval("\$str = \"$str\";");
    eval("\$str = \"$str\";");
    hphpd> echo $str. "\n";
    echo $str. "\n";
    This is a cup with my coffee in it.



    怎么不支持?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4639 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 04:10 · PVG 12:10 · LAX 21:10 · JFK 00:10
    ♥ Do have faith in what you're doing.