/    Sign up×
Community /Pin to ProfileBookmark

include a file in another folder

Hello there

As I use the include function on my pages, is there a way to include a file located in another folder, so for example.

The link is google.com/subfolder/index.php

and if I intergrate a php file that located @
google.com/includes/header.php

Thank for replies in advance

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 03.2008 — I often do it relative to the web document root:
[code=php]
include $_SERVER['DOCUMENT_ROOT'].'/includes/header.php';
[/code]
Copy linkTweet thisAlerts:
@HellusiusauthorDec 04.2008 — I found the missing link, the actual include came in through if I used the whole link of the folder, however, I did not take in account that I would have to copy the stylesheet into this folder as well(slap on the head)
Copy linkTweet thisAlerts:
@Joseph_WitchardDec 04.2008 — NogDog, would he be able to reference the stylesheet with a relative path? As in /stylesheets/mycss.css?
Copy linkTweet thisAlerts:
@NogDogDec 05.2008 — NogDog, would he be able to reference the stylesheet with a relative path? As in /stylesheets/mycss.css?[/QUOTE]

As an HTML path, yes. Just don't confuse HTML paths with file-system paths in your PHP code. In a HTML href/src attribute "/dir/file" indicates a file in directory named "dir" which is a sub-directory of the root web directory. As a PHP filesystem path it would (at least in UNIX/Linux) indicate a file in a directory named "dir" which is a subdirectory of the root filesystem directory (i.e. nothing to do with where the web document root directory is).
Copy linkTweet thisAlerts:
@Joseph_WitchardDec 05.2008 — Ah, okay. Thanks? I always use ../directory to get to the parent forum, but your way is probably better. In fact, I don't even remember why I started doing it that way. Do you need to use your method to access files outside of the document root? My host doesn't allow me to access stuff outside of my document root, so that might have been the original reason I chose that style.
×

Success!

Help @Hellusius spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...