简体   繁体   English

为什么Scandir()函数不起作用?

[英]Why is the Scandir() function not working?

I am getting the following php warning when using the scandir() function : 使用scandir()函数时,我收到以下php警告:

Scandir failed to open dir: opration not permitted in public_html/page2.php on line 3 Scandir无法打开目录:第3行的public_html / page2.php中不允许操作

page2.php page2.php

 <?Php
 $folder="/";
 $result=scandir($folder);
 print_r($result); 

I want to use this function to print the files and sub directories of my root folder but it's not working. 我想使用此功能来打印我的根文件夹的文件和子目录,但是它不起作用。

Does someone know how to fix it? 有人知道如何解决吗?

Because you're trying to scan a directory that you don't have permissions to do (in this case the root directory / ). 因为您正在尝试扫描没有权限的目录(在本例中为根目录/ )。

Either change the permissions, or scan a directory you do have permissions for. 更改权限,或扫描您确实具有权限的目录。

This may either be on a directory permissions basis, or using the open_basedir directive. 这可以基于目录权限,也可以使用open_basedir指令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM