473,378 Members | 1,351 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,378 software developers and data experts.

[Q] Working with Include

I've got a directory structure similar to this:

index.php

dirA
index.php

dirB
funcs.php

otherfuncs.php

in the root index.php, I've got:

require_once( dirB/funcs.php );

in funcs.php, I've got:

require_once( otherfuncs.php );

which works because the root index.php is the location from which files
are looked for.
In dirA/index.php, I've got:

require_once( ../dirB/funcs.php );

However, now, require_once( otherfuncs.php ) in funcs.php cannot be
found.
I can provide full a full path in each of the requires, but this would
lead to rather unstable code....or is this the right way to do things?

How do you work around this kind of issue?

Thank you.
--
== Eric Gorr ========= http://www.ericgorr.net ========= ICQ:9293199 ===
"Therefore the considerations of the intelligent always include both
benefit and harm." - Sun Tzu
== Insults, like violence, are the last refuge of the incompetent... ===
Jul 17 '05 #1
1 1486
Eric <eg*************@verizon.net> wrote:
I can provide full a full path in each of the requires, but this would
lead to rather unstable code....or is this the right way to do things?


Well, a solution I found to this problem was in dirA/index.php, to
chdir( ".." ); before the require_once ... is this the best way to solve
this problem?
Also, funcs.php contains statements of the form:

echo "<a href=\"directoryname\">linkname</a><br>";

forming a relative URL. Again, this would point to a different
location depending on whether dirA/index.php or SiteRootDir/index.php
called the function containing this relative URL.

I was able to find a solution by doing the following:

function AFunction( $toRoot )
{
$location = $toRoot . "locationFromSiteRootDir";
echo "<a href=\"$location\">linkname</a><br>";
}

So, from dirA/index.php, I would call AFunction like:

AFunction( ".." );

Is this the best way to solve this problem?

Thank you.
Jul 17 '05 #2

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

Similar topics

8
by: Jim | last post by:
Need some comments from anyone willing to help, please. See the code included below. This compiles with GCC on FreeBSD 4.7. The only point of it is to accept a socket connection. Nothing else...
17
by: Jonathan Burd | last post by:
Greetings everyone, Reading about the int64_t types added by C'99, I decided to implement a 64-bit version of atoi for my own library. However, for the test number provided, it isn't doing what...
5
by: Jeff Johnson | last post by:
I'm using forms authentication to protect a subfolder within my site. I've got it working fine except for two issues: (1) When I do a RedirectFromLogin page I have to put a cookie path ("/"...
4
by: darrel | last post by:
I'm trying to load an include dynamically. So, I'm writing out the include tag via a response.write: response.write("<!--#include virtual='" & contentIncludeFile &"' -->") however, that's...
12
by: sanjaymeher | last post by:
This piece of code is not working in windows but working in Unix Not getting the reason .. help me out #include <iostream.h> #include <stdio.h> #include <string.h> int addDynamicMemory(char...
4
by: Axter | last post by:
Sorry for OT question, but does any one have a working *.bat file to get Comeau to work with VC++ 7.1, VC++ 8.0, or GNU 3.x compilers. I've tried everything I can think off, to get it to work,...
10
by: sickboy | last post by:
Hey everyone, I am working on a new site, ForceFedTV.com and I have gotten reports that the site runs great on mac, but once loaded on a pc, after clicking a few links then going back to the home...
0
by: George2 | last post by:
Hello everyone, From the definition of working set, it is a subset of virtual pages resident in physical memory -- from book Windows Internals. It means working set could not be larger than...
3
by: benoypaul | last post by:
I am using an include file in my php program. This include file is not working with php program file ,but it is working with ...
6
by: josequinonesii | last post by:
I've searched, I've read, I've tested and re-read numerous post but to no avail yet... Quite simply, the settings I've applied to my httpd.conf, httpd-vhost.conf and my hosts files simply does not...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.