从父文件夹扫描其他目录

时间:2013-06-18 17:06:31

标签: php scandir

/home/name_a/folder/public_html/index.php脚本:

include_once('/home/name_b/folder/public_html/index.inc.php');

index.inc.php脚本:

define("ROOT", __DIR__ ."/");
$pages_dir = 'pages';
include ($page_dir.'/'.filename.php');
$pages = scandir($pages_dir, 0);
print_r($page);

我的问题是,包含文件工作正常(/home/name_b/folder/public_html/pages/filename.php),但scandir会查找/ home / name_a / folder / public_html / pages。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

尝试以这种方式定义pages_dir:

$pages_dir = dirname(__FILE__) . '/pages/';