今天看了一天的ecmall源代码,有个地方实在想不通,
$source="fetch('themes/default/resource/header.html'); ?>
fetch('themes/man/resource/man.html'); ?>
fetch('themes/default/resource/footer.html'); ?>";
然后执行_eval($source)
_eval函数代码为
    function _eval($content)
    {
        ob_start();
        eval('?' . '>' . trim($content));        $content = ob_get_contents();
        ob_end_clean();
        return $content;
    }
fetch是ecmall里面的一个函数,
不能理解为什么eval('?' . '>' . trim($content));?
感觉应该是eval('<' . '?' . trim($content));才对吧,
请大虾莫笑,帮忙

解决方案 »

  1.   

    eval('?>html code here');先当于模拟以下红色部分
    <?php
    echo "hello world"
    ?>
    <!-- $content -->
    <input type='text' value='aaaa'/>
      

  2.   


    <?php
    echo "hello world"
    <?
    <!-- $content -->
    <input type='text' value='aaaa'/>

    eval('<? html code here')相当于以上红色部分,明显是错误的.
    你能这么写php代码么?
    =====================
    <?php
    <? <input type='text' value='aaaa'/>
      

  3.   

    但是$source="fetch('themes/default/resource/header.html'); ?>
    fetch('themes/man/resource/man.html'); ?>
    fetch('themes/default/resource/footer.html'); ?>";
    这样的话后面的?>做什么用的呢?
      

  4.   

    昂……?
    拼完的代码不是这样的么?function _eval($content)
        {
            ob_start();
            eval('?>fetch('themes/default/resource/header.html'); ?>fetch('themes/man/resource/man.html'); ?>fetch('themes/default/resource/footer.html'); ?>');        $content = ob_get_contents();
            ob_end_clean();
            return $content;
        } 
      

  5.   

    这可能得联系你的上下文代码了,比如
    $html = _eval($content);
    然后对$html又做了什么处理,光靠这几行代码,看不出有什么蹊跷.