Question

/home/name_a/folder/public_html/index.php script:

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

index.inc.php script:

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

My question is, the include file works fine (/home/name_b/folder/public_html/pages/filename.php) but the scandir looks for /home/name_a/folder/public_html/pages instead. Any idea?

Was it helpful?

Solution

Try to define pages_dir this way:

$pages_dir = dirname(__FILE__) . '/pages/';
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top