Jump to content


Photo

Questions about file includes and include_path


  • Please log in to reply
1 reply to this topic

#1 mmosel

mmosel
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 16 April 2006 - 06:03 AM

Hi all,

I've been humming right along developing my site locally. Until today I haven't had a set include_path in my php.ini file. Haven't needed it. This has allowed me to do the following type of include with php:

say I have directory 1 and within directory 1 I have two sub directories - a & b.

Now say I have a script that I run in directory 1.

This script includes a file in directory a, like this:

include 'a/test.php';

Now, inside of test.php I have another include statement - include 'b/test2.php';

This works great. No need to back out of the directory or anything. PHP simply finds the file in directory b.

Now, if I define the include_path in my php.ini (say for a PEAR install) - now the type of include above doesn't work AT ALL!!! I'm stumped! It will include the first file, but if the second file isn't in directory a, all of a sudden it spits out an error saying that the file can't be found anymore (and it looks in the PEAR directory).

So, is there a way to have both? I really like the standard way, in fact, most of my scripts are setup this way.

Help!!

#2 mmosel

mmosel
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 16 April 2006 - 08:09 AM

[!--quoteo(post=365232:date=Apr 16 2006, 01:03 AM:name=mmosel)--][div class=\'quotetop\']QUOTE(mmosel @ Apr 16 2006, 01:03 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Hi all,

I've been humming right along developing my site locally. Until today I haven't had a set include_path in my php.ini file. Haven't needed it. This has allowed me to do the following type of include with php:

say I have directory 1 and within directory 1 I have two sub directories - a & b.

Now say I have a script that I run in directory 1.

This script includes a file in directory a, like this:

include 'a/test.php';

Now, inside of test.php I have another include statement - include 'b/test2.php';

This works great. No need to back out of the directory or anything. PHP simply finds the file in directory b.

Now, if I define the include_path in my php.ini (say for a PEAR install) - now the type of include above doesn't work AT ALL!!! I'm stumped! It will include the first file, but if the second file isn't in directory a, all of a sudden it spits out an error saying that the file can't be found anymore (and it looks in the PEAR directory).

So, is there a way to have both? I really like the standard way, in fact, most of my scripts are setup this way.

[/quote]


Well - I stumbled upon the solution. It was hard to track down! But it's simple (isn't in always? no, not really)

Anyway, you just have to place a single period . and then the separator (which is either a ; or : depending upon your setup) So I just added the " . ; C:\path to pear" and now my relative includes work again. Whew!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users