Reputation: 9011
I am trying to include a file in a PHP script using a relative path. However, the function returns an error stating that the file doesn't exist.
It does exist - I have attached a file structure screenshot too - and other pages can include it without issue.
require_once("../config.php");
Warning: require_once(../config.php): failed to open stream: No such file or directory in /www/sites/c84/7de/example.com/web/inc/sections.php on line 25
Fatal error: require_once(): Failed opening required '../config.php' (include_path='.:/usr/share/php:/usr/share/pear') in /www/sites/c84/7de/example.com/web/inc/sections.php on line 25
File Structure Screenshot
Upvotes: 1
Views: 1649
Reputation: 212522
/www/sites/c84/7de/example.com/web/inc../config.php
requires a /
after inc
and before ..
/www/sites/c84/7de/example.com/web/inc/../config.php
so something like
require_once(__DIR__ . '/../config.php');
Upvotes: 2