doukengzi3517 2014-02-18 10:32
浏览 53

php Scandir()错误是因为我还是wampserver?

When I use this code (below) it gives me 3 errors. Is it me or Wampserver? What should I do?

<?php
$dir = "/gallery/";
$o = scandir($dir);

print_r($o);
?>

Error 1:

Warning: scandir(/gallery/,/gallery/) [<a href='function.scandir'>function.scandir</a>]: The system cannot find the file specified. (code: 2) in C:\wamp\wwwandom1\index.php on line 3

Error 2:

Warning: scandir(/gallery/) [<a href='function.scandir'>function.scandir</a>]: failed to open dir: No such file or directory in C:\wamp\wwwandom1\index.php on line 3

Error 3:

Warning: scandir() [<a href='function.scandir'>function.scandir</a>]: (errno 2): No such file or directory in C:\wamp\wwwandom1\index.php on line 3
  • 写回答

2条回答 默认 最新

  • dongxun6458 2014-02-18 10:35
    关注

    You are searching for the /gallery/ directory. The first / means it'll start searching from the root. Removing that will make it relative. So change

    $dir = "/gallery/";
    

    to

    $dir = "gallery";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程