Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
How to get a PHP file to be included across files in different directories?
Old 11-22-2009, 02:18 AM How to get a PHP file to be included across files in different directories?
Junior Talker

Posts: 3
Name: Bips
Trades: 0
Hi,

Currently I have created some php based webpages and uploaded them to my web hosting server.It has a PHP 5.1.6
installed.With this I am able to include files only that are in the same directory(they work well using require() fn).If not an error message displaying some "no such file" in directory appears in the page.I would like to use them to be included in different direcetories.What should I do?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Bips123 is offline
View Public Profile
 
 
Register now for full access!
Old 11-22-2009, 02:46 AM Re: How to get a PHP file to be included across files in different directories?
webwest's Avatar
Experienced Talker

Posts: 42
Name: Dan Whims
Location: Los Angeles, CA
Trades: 0
Code:
<?php include 'some/other/directory/file.php'?>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

One-stop Web Development Shop since 1995
webwest is offline
View Public Profile Visit webwest's homepage!
 
Old 11-22-2009, 03:48 AM Re: How to get a PHP file to be included across files in different directories?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
self promo link drop - http://www.candsdesign.co.uk/article.../php-includes/
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
View Public Profile Visit chrishirst's homepage!
 
Old 11-24-2009, 12:56 PM Re: How to get a PHP file to be included across files in different directories?
kcmartz's Avatar
Super Talker

Latest Blog Post:
~Gri to Kcmartz~
Posts: 120
Name: Kenson
Location: Washington, USA
Trades: 0
I think that this will work, for example, a link one directory back and into another directory.

EX:
........................<File A
...............<dirA<
HomeDir <.........<File B
.............<.........<File A
...............<dirB<
........................<File B

You would link it like this, I think:
*From

<?php include("../dirB/fileb.php"); ?>

That would include a file from dirb, fileb, to dira, filea, for example.

(I THINK THAT THIS IS IT)
__________________
Thanks,

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
for problems/site.
kcmartz is offline
View Public Profile Visit kcmartz's homepage!
 
Old 07-12-2010, 03:38 PM Re: How to get a PHP file to be included across files in different directories?
Junior Talker

Posts: 1
Name: Bob
Trades: 0
The answer to your questions, however, is by using relative paths.

Do a quick search for: php includes relative paths

It's pretty easy stuff. You'll get the hang of it quickly. Here are a couple quick examples...

file.php - this refers to file.php in the current directory.
./file.php - this also refers to file.php in the current directory.
../file.php - this refers to file.php in the parent directory to where you are calling it from.
./dir/file.php - this refers to file.php in a subdirectory called 'dir' underneath the directory you are calling it from.

Hope that helps a little.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
businessesinct is offline
View Public Profile
 
Old 07-12-2010, 03:45 PM Re: How to get a PHP file to be included across files in different directories?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
I cannot remember anymore how many time this has been answered.
Rely on the $_SERVER['DOCUMENT_ROOT'] variable.

If you put all your functions in a file named fxs.php, in a directory named "includes" at the root of your web site, to always include it, anywhere in the site, it would be
PHP Code:
include($_SERVER['DOCUMENT_ROOT']."/includes/fxs.php"); 
$_SERVER['DOCUMENT_ROOT'] points to the root folder of your web site on the server.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
View Public Profile Visit tripy's homepage!
 
Old 07-15-2010, 06:10 AM Re: How to get a PHP file to be included across files in different directories?
Banned

Posts: 3
Name: Steve Lawrance
Trades: 0
I don't have enough experience with PHP and I want to dig into PHP. Can some one here give me any suggestions regarding PHP?
stevelawrance is offline
View Public Profile
 
Old 07-15-2010, 06:55 AM Re: How to get a PHP file to be included across files in different directories?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Start by reading the manual: http://www.php.net/manual/en/langref.php

And don't hijack existing threads. Start a new one next time.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
View Public Profile Visit tripy's homepage!
 
Closed Thread     « Reply to How to get a PHP file to be included across files in different directories?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27152 seconds with 12 queries