I am trying to include a connect file values one level above the public_html level(not my idea).
I'd like to have one connect file in the public_html root that includes the link and can use the values to connect to the db but I haven't been able to - so I use a connect file in each folder root.
I've attempted using dynamic links like:
$_SERVER['DOCUMENT_ROOT']/filename.php
but the only way I can get to that include
../filename.php
OR if it's inside a folder I need to make the include link :
../../filename.php
Any ideas?
EDIT :
both have worked for me
include "{$_SERVER['DOCUMENT_ROOT']}/../filename.php";
dirname($_SERVER["DOCUMENT_ROOT"]);
My Answer:
($_SERVER['DOCUMENT_ROOT'] . '/filename.php');
include('../filename.php');
Both of these methods should work for including a file from a higher level directory in PHP. Just make sure that the file path is correct and that the file you are trying to include actually exists in the specified location.
Rate this post
5 of 5 based on 8821 votesComments