473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

including files - paths

If I'm working on a project, I'll usually create a folder to contain all
the project files before uploading this to the root of the production
server. The trouble is that if I do:
include('/myfile.php')
this looks at the root of local host, as it should and not at the root
of the working directory. It means that if I want to use absolute
links, I have to change them before I upload.

Or am I missing something blindingly obvious?

I'm pretty sure this has been done before (FAQ entry material?), but not
for a while. :-)
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
Jul 17 '05 #1
3 1394
Geoff Berrow wrote:
If I'm working on a project, I'll usually create a folder to contain
all the project files before uploading this to the root of the
production server. The trouble is that if I do:
include('/myfile.php') this looks at the root of local host, as it
should and not at the root of the working directory. It means that
if I want to use absolute links, I have to change them before I
upload.
Change or extend your local configuration so that it reflects the
configuration at the remote server.

An easy way is creating a virtual host on your local box with a
documentroot pointing to the wannabe /...
Or am I missing something blindingly obvious?

No, I don't think so

Hans

--
"He who asks a question is a fool for five minutes;
he who does not ask a question remains a fool forever"
Jul 17 '05 #2
I noticed that Message-ID: <42*********************@news.xs4all.nl> from
Hans van Kranenburg contained the following:
Change or extend your local configuration so that it reflects the
configuration at the remote server.

An easy way is creating a virtual host on your local box with a
documentroot pointing to the wannabe /...


Any idea where I might find instructions on how to do that?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3
Geoff Berrow wrote:
If I'm working on a project, I'll usually create a folder to contain all the project files before uploading this to the root of the production
server. The trouble is that if I do:
include('/myfile.php')
this looks at the root of local host, as it should and not at the root of the working directory. It means that if I want to use absolute
links, I have to change them before I upload.
The quick solution is to use relative path (something like
.../foo.php or ./foo.php). But, if we use relative path for all
includes, it will hit performance. So, I use something like:

<?php
//config.inc.php
$CFG['project_path'] = '/home/foo/foo/';
//etc etc
?>

<?php
//foo.php
require_once('../common/config.inc.php'); //relative to project
require_once($CFG['project_path'] . 'html/header.html'); //absolute
//etc etc...
require_once($CFG['project_path'] . 'html/footer.html'); //absolute
?>

As seen, only one path is relative. I even have a mechanism to auto
detect the project path in config.inc.php.
I'm pretty sure this has been done before (FAQ entry material?), but not for a while. :-)


Yes, this has to be included in FAQ. But, what could be an
appropriate question?

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Brian van den Broek | last post by:
Hi all, I'm just starting to employ unit testing (I'm using doctest), and I am uncertain how to handle writing tests where the behaviour being tested is dependant on whether certain file paths...
2
by: jordan | last post by:
I'm using the Server.Execute method to include a static page inside a dynamic database call. This static page is not a valid HTML page (i.e. lacking <body>,<head>, etc. elements), but I'm pulling...
2
by: shruti | last post by:
hiii all I'm tryin to call a perl script from a C program in following 2 ways- 1.By callin system function. But there's some problem because the system function is not able to executeany...
1
by: shruti | last post by:
hiii all I'm tryin to call a perl script from a C program in following 2 ways- 1.By callin system function. But there's some problem because the system function is not able to executeany...
1
by: Martin Mücke | last post by:
I got a website consisting of about 150 php pages. The site uses a frameless table based design. Header and menu are always the same and therefore should be extracted. At the moment I got a...
12
by: duzhidian | last post by:
failed to open stream: No such file or directory I have the programs like this structure: a.php is locate at . b.php is located at ./lib c.php is located at ./lib/sublib a.php uses a...
3
by: Alexander Vasilevsky | last post by:
Here, there is a challenge: to find the files must be on a local computer, have the same names. Get drives and folders to go through without problems. But what and how to store files while a...
10
by: kimiraikkonen | last post by:
Hi, I have an app which has a listbox and when i double click an associated fileS, i want their paths to be added into listbox in my application. This code works good when i try to open a...
0
by: VigneshS | last post by:
Hi, I am a newbie to Globalization and Localisation Concepts. I tried almost all the methods of the Globalization concepts. But i cannot be able to embed a text file within a Resource. ...
12
by: Hongyu | last post by:
Dear all: I am trying to write to a file with full directory name and file name specified (./outdir/mytestout.txt where . is the current directory) in C programming language and under Unix, but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.