Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

relative include from symbolic linked file

Status
Not open for further replies.

lumberjakel

Programmer
Oct 27, 2001
29
NL
Description:
------------
On my development server I have a directory:
/var/containing the file:
menu.inc
dbsettings.inc
and the symbolic links
db_mysql.inc -> /var/export/db_mysql.inc
subdir -> /var/export/subdir

In the directory /var/export:
db_mysql.inc
In the directory /var/export/subdir:
include.inc

The file db_mysql.inc has the following line:
require_once("dbsettings.inc");
The file include.inc has the following line:
require_once("../menu.inc");

What happens is that the include_path is ".", so the file ../menu.inc
cannot be found by include.inc

I tried to set the include_path to /var/ This worked for the
file db_mysql.inc, but it didn't work for menu.inc. I tried to set the
include path to ".:/var/ but then the file dbsettings.inc
couldn't be found.
I also tried "/var/ and lots of other
combinations.

On a release server the two directories are merged so there will be no
symlinks. (The problem I have does not occur on this server)

I googled lots of hours, but didn't find any thing useful.
I expected PHP to open the symlinked files as if they were actually
there.
Can I configure PHP to do so?

Reproduce code:
---------------
/var/export/db_mysql.inc:
require_once('dbsettings.inc');

/var/export/subdir/include.inc:
require_once('../menu.inc');

/var/$menu = array( ... );

/var/$host = 'localhost';
$user = '...';
...

symlinks:
/var/ -> /var/export/db_mysql.inc
/var/ -> /var/export/subdir

Expected result:
----------------
I expected PHP to open the symlinked files as if they were actually
there.

Actual result:
--------------
Warning: main(../menu.inc): failed to open stream: No such file or
directory in /var/export/subdir/include.inc on line 4

Fatal error: main(): Failed opening required '../menu.inc'
(include_path='/var/ in /var/export/subdir/include.inc on line
4
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top