mmosel Posted April 16, 2006 Share Posted April 16, 2006 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!! Quote Link to comment https://forums.phpfreaks.com/topic/7525-questions-about-file-includes-and-include_path/ Share on other sites More sharing options...
mmosel Posted April 16, 2006 Author Share Posted April 16, 2006 [!--quoteo(post=365232:date=Apr 16 2006, 01:03 AM:name=mmosel)--][div class=\'quotetop\']QUOTE(mmosel @ Apr 16 2006, 01:03 AM) [snapback]365232[/snapback][/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! Quote Link to comment https://forums.phpfreaks.com/topic/7525-questions-about-file-includes-and-include_path/#findComment-27410 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.