473,398 Members | 2,525 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,398 software developers and data experts.

directory paths...how does this work?

In ASP/IIS if I want to point to a folder/directory in the root as an
in include I write this...

<!--#include virtual="/menu.asp" -->

In PHP/Apache I have to do this...
<?php include "menu.php" ?> or something like this....

My problem is in asp I can reference this file from any
folder/directory. For example, if I were here.... "/admin/default.asp"
I could reference the include as is. In php I can't do this, at least
I don't know how to. Another problem is that if there are file paths
in the include itself this problem comes up again. I know I could
write this <?php include "../menu.php"?> and it would find it's way to
the file but what about the file paths in the include? This is a menu
with relative paths to images.

How can I point at a file in the root from any directory in my website
using a relative path? I know I should probably avoid an http://
reference.

Thanks!!

Jan 6 '06 #1
3 2203
On 2006-01-06, John K <ki*****@yahoo.com> wrote:
My problem is in asp I can reference this file from any
folder/directory. For example, if I were here.... "/admin/default.asp"
I could reference the include as is. In php I can't do this, at least
I don't know how to. Another problem is that if there are file paths
in the include itself this problem comes up again. I know I could
write this <?php include "../menu.php"?> and it would find it's way to
the file but what about the file paths in the include? This is a menu
with relative paths to images.


PHP has a configuration setting include_path.
Apart from setting it in php.ini you can also change it at runtime
(http://www.php.net/ini_set).
And you can manipulate it with http://www.php.net/get_include_path and
http://www.php.net/set_include_path

The only problem you might experience is that paths are separated with ; on
windows platforms and with : on unix platforms. To avoid this i suggest you take
an approach as following:

$include_paths = array('.', '..', '/var/somewhere' , get_include_path());
ini_set('include_path', implode(PATH_SEPARATOR, $include_paths));
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be>
Jan 6 '06 #2
John K wrote:
In ASP/IIS if I want to point to a folder/directory in the root as an
in include I write this...

<!--#include virtual="/menu.asp" -->

In PHP/Apache I have to do this...
<?php include "menu.php" ?> or something like this....

My problem is in asp I can reference this file from any
folder/directory. For example, if I were here.... "/admin/default.asp"
I could reference the include as is. In php I can't do this, at least
I don't know how to. Another problem is that if there are file paths
in the include itself this problem comes up again. I know I could
write this <?php include "../menu.php"?> and it would find it's way to
the file but what about the file paths in the include? This is a menu
with relative paths to images.

How can I point at a file in the root from any directory in my website
using a relative path? I know I should probably avoid an http://
reference.

Thanks!!


Check out $_SERVER['DOCUMENT_ROOT']. It always points to the root
directory of your web site, no matter where that is.

You could, for instance, do something like:

<?php include($_SERVER['DOCUMENT_ROOT'] . '/include/menu.php'); ?>

or similar.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jan 6 '06 #3
As it's turning out this entire problem "isn't" a problem on the live
server. I'm using XAMPP to develop locally and it appears this problem
is coming from there? I haven't throughly tested on the live server
yet but someone demonstrated to me that the absolute paths "do" work
there, they just don't on XAMPP. It may yet turn out to no be this
simple but we'll see.

Are there any XAMPP experts out there?

Jan 9 '06 #4

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

Similar topics

1
by: Fuzzyman | last post by:
I wish to restrict access to a program to certain directories. I also wish to prevent access to certain directories. What this means is that given a path, I need to work out if that path is in a...
2
by: ngposter | last post by:
Try the following code snippet: Directory.CreateDirectory(@"C:\Folder1\"); Directory.Move(@"C:\Folder1\", @"C:\Folder2\"); Directory.Delete(@"C:\Folder2\"); After executing, a C:\Folder1...
8
by: nick | last post by:
I have a problem and I've been using a cheezy work around and was wondering if anyone else out there has a better solution. The problem: Let's say I have a web application appA. Locally, I set...
3
by: KSC | last post by:
Hello, Is there a way to programmatically determine if a directory is shared and if so, what the sharename is? It seems a simple question, but I have been searching and not found the...
11
by: comp.lang.php | last post by:
Once again, I thought my class method deleteZip() would do the trick, but it never deletes any .zip* file found in a directory: /** * Delete any latent ZIP files found in this album. This...
15
by: Sandra-24 | last post by:
Comparing file system paths as strings is very brittle. Is there a better way to test if two paths point to the same file or directory (and that will work across platforms?) Thanks, -Sandra
14
by: gio | last post by:
I have a problem and the solution should works under windows and unix OS. Suppose I have a program ex.c in the directory X (so the current working directory of ex.c is X). Also suppose I have...
6
by: titan.nyquist | last post by:
The WebBrowser control won't load a css file written in the same directory as the program. If I put an absolute path to it, it will load it. Thus, the current directory of the WebBrowser control...
4
by: tshad | last post by:
I have a site www.stf.com and a site www.stfstage.com (where I do all my testing). The problem is that www.stfstage.com is only internal and I need to get access from the outside (without...
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:
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.