<?PHP
$dir=dir('./');
while($entry=$dir->read()){
     if(!is_file($entry)) {continue;}
     $handle=fopen($entry,"r");
     while($buffer=fgets($handle,4096)){
           $buffer=trim($buffer);
           if(ereg("title*=*\"",$buffer)){
             
              eval ($buffer);
              $linknm=$title;
              break;
           }     
     }    

?>
请问这个代码的eval()有什么问题?
怎么老是提示错误:Parse error: syntax error, unexpected '<' in D:\AppServ\www\navbar.inc(10) : eval()'d code on line 1

解决方案 »

  1.   

    mixed eval ( string $code_str )
    Evaluates the string given in code_str as PHP code. Among other things, this can be useful for storing code in a database text field for later execution. There are some factors to keep in mind when using eval(). Remember that the string passed must be valid PHP code, including things like terminating statements with a semicolon so the parser doesn't die on the line after the eval(), and properly escaping things in code_str . To mix HTML output and PHP code you can use a closing PHP tag to leave PHP mode. Also remember that variables given values under eval() will retain these values in the main script afterwards. 
      

  2.   

    eval 是将字符串当作php代码运行,所以你的$buffer必须是没有错误的php代码才行
      

  3.   

    $buffer里的字符串有语法错误。
      

  4.   

    eval 的参数必须是合法的php语句