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

Reply
How to get a PHP file to be included across files in different directories?
Old 10-30-2010, 04:58 AM How to get a PHP file to be included across files in different directories?
Junior Talker

Posts: 1
Name: ThomasHansen jose
Location: sanit louis
Trades: 0



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
ThomasHansen is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-30-2010, 05:05 AM Re: How to get a PHP file to be included across files in different directories?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
You can either use an absolute path or use a relative path, but use .. to refer to parent directories.

For example, if your script is in the directory '/home/yoursite/public_html/foo/foo.php' and you want to include a file in the parent directory called bar.php you could do it one of two ways:
PHP Code:
include('/home/yoursite/public_html/bar.php');
//or
include('../bar.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
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 10-30-2010, 05:07 PM Re: How to get a PHP file to be included across files in different directories?
jim1228's Avatar
Extreme Talker

Posts: 195
Name: Jim
Location: Ohio
Trades: 0
or use:

PHP Code:
include_once("../bar.php"
This will help down the road
jim1228 is offline
Reply With Quote
View Public Profile Visit jim1228's homepage!
 
Old 10-30-2010, 05:27 PM Re: How to get a PHP file to be included across files in different directories?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
PHP Code:
<?php include($_SERVER['DOCUMENT_ROOT']."/include/inc_nav.php")?>
__________________
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
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « 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.13734 seconds with 12 queries