0

How to include something that is a directory before the file

like:
public_html/includes/sources/yt.php

the file yt.php must include a file which is in:
public_html/includes/fetch.php

what will it be like? include_once(../file.php) or?:'(

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by diafol
0

that's pretty much it. It's usually better to use absolute paths ie., /srv/www/public_html/includes/fetch.php but on shared hosting that might not be an option so ../file.php works just as well.

0

that's pretty much it. It's usually better to use absolute paths ie., /srv/www/public_html/includes/fetch.php but on shared hosting that might not be an option so ../file.php works just as well.

I have to agree. However, if for some reason the site has to be moved, the use of $_SERVER['DOCUMENT_ROOT'] instead of the /srv/www/public_html may be better. I usually put this into a constant called ROOT: include_once(ROOT . '/includes/fetch.php'); .

Mind you, placing a variable into a constant may be a bit suspect.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.