Terman
Terman

Reputation: 983

Referencing a file in a parent directory

Is this the right way to go about referencing a file in a parent directory relative to a php source file?:

require_once('../referenced_file.php');

Upvotes: 0

Views: 3624

Answers (1)

Yacoby
Yacoby

Reputation: 55445

To include a file relative to the current source file you should use the full path:

require_once dirname(__FILE__) . '/../referenced_file.php';

As the current working directory is set to the directory of the script that was initially executed.

Upvotes: 8

Related Questions