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?:'(
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?:'(
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.
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.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.