473,781 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Includes with muli-level directories

FP
I have the following files;
\A.php
\F1\B.php
\F1\F1_1\C.php

File A has the lines "echo 'A'; include_once('F 1/B.php');"
File B has the lines "echo 'B'; include_once('F 2/C.php');"
File C has the line "echo 'C';"

If I open file A in my browser I get "ABC".
If I open file B in my browser I get "BC".
So far so good.
I also have files;
\D.php
\F1\E.php
\F1\F1_1\F.php

File D has the lines "echo 'D'"
File E has the lines "echo 'E'; include_once('. ./D.php');"
File F has the line "echo 'F'; include_once('. ./E.php');"

If I open file E in my browser I get "ED".
If I open file F in my browser I get "FE" and an error saying file D
doesn't exist.
If I change the include portion of file E to '../../D.php' then I get
"FED".

Is this how PHP is suppose to work?
I have several files at the root level including a "SetupData. php" file
in which I need to specify IPs, passwords etc.
I have a directory "FX" and the file "ImageProxy.php " inside it.
The "ImageProxy.php " file is used as an include by files at the root
level but also called directly.
The "ImageProxy.php " file requires passwords stored in the
"SetupData. php" file.
How do I get the "ImageProxy.php " file to access the variables in the
"SetupData. php" file?
As far as I can tell it's possible to include a file by full path, if
possible I would like to avoid that, are there any other ways?

Jun 16 '06 #1
2 1228
FP wrote:
I also have files;
\D.php
\F1\E.php
\F1\F1_1\F.php

File D has the lines "echo 'D'"
File E has the lines "echo 'E'; include_once('. ./D.php');"
File F has the line "echo 'F'; include_once('. ./E.php');"

If I open file E in my browser I get "ED".
If I open file F in my browser I get "FE" and an error saying file D
doesn't exist.


Please check the PHP manual on include function:
"If filename begins with ./ or ../, it is looked only in include_path
relative to the current working directory."
Please use the http://www.php.net/getcwd in your D,E,F scripts to check
what is current directory. I suspect that when the E.php is evaulated
in context of E.php, the working directory is still \F1\F1_1 so the
include_once('. ./D.php'); is trying to include \F1\F1_1\..\D.p hp, which
is does not exist.

Sincerely,
Alexander
http://www.alexatnet.com

Jun 16 '06 #2
FP
AlexVN wrote:
Please use the http://www.php.net/getcwd in your D,E,F scripts to check
what is current directory. I suspect that when the E.php is evaulated
in context of E.php, the working directory is still \F1\F1_1 so the
include_once('. ./D.php'); is trying to include \F1\F1_1\..\D.p hp, which
is does not exist.


You're right, just tried the "getcwd" command and the working directory
for all three files was always \F1\F1_1\

Thanks

Jun 17 '06 #3

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

Similar topics

13
2741
by: Tim Tyler | last post by:
A fairly simple question: I have a library A which depends on library B and C. Currently I have: <?php include("A.inc.php"); include("B.inc.php"); include("C.inc.php");
2
1611
by: Joe Mowry | last post by:
First off, I'm posting this question for a friend that doesn't have access to the news groups. Problem: Using PHP as the base and has several PHP < includes > for various functions, all this by its self works just fine. Failure occurs on adding the XML include. Here's the wierd: If all the PHP includes are removed/commented out,
4
1635
by: Patrick | last post by:
I have an ASP site with about 50 ASP files, all of which are currently including a common "includes.asp" file near the top of the file, responsible for generating the <HEAD/> section of the HTML I need to make a change for 3 of those ASP files such that some dynamic HTML is generated in the <HEAD/> section. I want those dynamic HTML to appear only for 3 specific ASP files. Is there a more elegant way other than to 1) Dim...
4
1780
by: Generic Usenet Account | last post by:
I am seeing some unexpected behavior while using the STL "includes" algorithm. I am not sure if this is a bug with the template header files in our STL distribution, or if this is how it should work. For your benefit, let me first quote from the STL Standard Reference (Stepanov & Lee): template <class InputIterator1, class InputIterator2> bool includes(InputIterator1 first1, InputIterator1 last1,InputIterator2 first2, InputIterator2...
2
7679
by: David Muoio | last post by:
I am trying to validate an XML file against an XSD that is stored in the assembly as an embedded resource. I can get it to work as long as the XSD does not include other XSDs. After a fair amount of searching, I have found 3 possible solutions but none have worked for me. They are: 1. Use the Includes property of XmlSchema to add included XSDs, then call Compile XmlSchema mainSchema = XmlSchema.Read( stream1, null ); XmlSchema ...
8
1926
by: Jim | last post by:
Hi: Do we have some common style for includes when working on a project with lots of c and h files. Wat I mean is do we have a rule in C when a file includes several files and those file in turn can call back it. So do we keep the includes in the source file or in its header file and just call the header from the c file. Are there any more rules when we go for includes. Thanx to yu all who bother to share.... su
12
2994
by: tshad | last post by:
I am not sure why I am getting this error: I have the following code I want to run from another include file that holds all my functions. functions.inc ************************************************************************************ <Script runat="Server"> Sub fnHeader(client As String) response.write("<!-- #include file = ../includes/staffingHeaders.inc -->")
3
2539
by: Jeff | last post by:
I have an asp page. Now I know this is sortof OT, but I am not sure of the forum to get an answer. I have an include on this asp page <!-- #include file=\forum\includes\consts-inc.asp --> now, it gives me this error: File attribute '\forum\includes\consts-inc.asp' cannot start with forward slash or back slash.
7
2485
by: Ajinkya | last post by:
I have writen a program for a game called game.exe Now it includes a player part to which has to be a function to be writen by someone else. Now I want to provide this exe to some tester who will be writing his player function. I dont know his file name and his function name....he will have to include it. I am providing him the game.exe and a common file containing all the
1
1680
by: JRough | last post by:
I have includes at the top of the file and I have inline includes also includes in mysql queries. For example: include './includes/config.inc.php'; include $include_path.'dates.inc.php'; include $include_path.'auction_types.inc.php'; include $include_path.'countries.inc.php'; include $include_path.'datacheck.inc.php'; include $include_path.'wordfilter.inc.php'; include $include_path.'converter.inc.php';
0
9639
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10308
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10076
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9939
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8964
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7486
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4040
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.