/    Sign up×
Community /Pin to ProfileBookmark

Accessing files in a parent directory

Is it possible to access files using:

include(“”);

in a parent directory without using
the entire web address?

I have to edit many of the same files
over and over because I use them
in different directories. If I transfer
to a different domain, I have to go in
and edit everyone of them.

However, if I could access the parent
directory, it would solve this problem.

Example:

[code=php]www.domain.com/config/config.php[/code]

is commonly used, yet I need to access it
from a different directory:

/public/index.html …

[code=php]
code…

include(“www.domain.com/config/config.php”);

code…[/code]

Couldn’t I use something like:

[code=php]
include(“\config/config.php”)
[/code]

Which I know does not work, but I’m sure there’s
a way to do it.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 20.2010 — ".." is shorthand for "up one directory", e.g.:
[code=php]
include "../file.php";
[/code]
Copy linkTweet thisAlerts:
@anothenauthorNov 20.2010 — thx NogDog,

You just saved me hours of editing

files all night.

I take it that I can use the same method

for css and .js files too?

[code=php]
<LINK href="../../CSS/stylesheet.css" rel="stylesheet" type="text/css">

<script type="text/javascript" src="../../calendar.js"></script>

[/code]
×

Success!

Help @anothen 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.22,
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,
)...