duanqiangwu9332 2014-05-05 14:55
浏览 42
已采纳

解析错误:语法错误,第9行C:\ xampp \ htdocs \ php \ dir.php中的意外“文件名”(T_STRING)[关闭]

**php program for reading filenames and filetypes from a dir.**

it shows the syntax error : Parse error: syntax error, unexpected 'filename' (T_STRING) in C:\xampp\htdocs\php\dir.php on line 9

<?php
$dir="C:\xampp\htdocs\php\"; 
if(is_dir($dir)) 
 {
 if($dirref=opendir($dir))
   {
     while(($file=readdir($dirref))!==false)
      {
      echo "filename : $file : filetype: ".filetype($dir.$file)."
";
      }
   closedir($dirref);
   }
 }
?>
  • 写回答

4条回答 默认 最新

  • doushi9856 2014-05-05 15:03
    关注

    It appears you've escaped the closing quotes on your $dir= statement. I don't use php in a Windows environment, so I don't know if you can convert all your \ to /, but if not, you'll want to escape all the \:

    $dir="C:\\xampp\\htdocs\\php\\"; 
    

    Or use single quotes, which disables escape sequences:

    $dir='C:\xampp\htdocs\php\'; 
    

    Parse errors often indicate that there is a syntax (or string in this case) error in your code, BEFORE the error actually reported by the parser.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥30 关于#opencv#的问题:使用大疆无人机拍摄水稻田间图像,拼接成tif图片,用什么方法可以识别并框选出水稻作物行
  • ¥15 Python卡尔曼滤波融合
  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1