Setting include path for PHP

Web hosting, FTP/database access, mirror services and hosted blogs
Post Reply
cocoboy
Posts: 7
Joined: Fri Nov 17, 2006 10:56 pm

Setting include path for PHP

Post by cocoboy » Fri Mar 06, 2009 10:50 pm

HI All
How do I go about setting an include path in the php.ini file given I dont have access?
I have tried using the .htaccess file but causes pages to fail to load.
Tried placing a php.ini file in the directory where I was testing the path and didnt work either.
Any help appreciated.
coco

JasonM

Re: Setting include path for PHP

Post by JasonM » Fri Mar 06, 2009 11:42 pm

Can you advise why you would need to adjust that setting?
Couldn't you simply include the path when you include the file?

cocoboy
Posts: 7
Joined: Fri Nov 17, 2006 10:56 pm

Re: Setting include path for PHP

Post by cocoboy » Fri Mar 06, 2009 11:55 pm

Can you advise why you would need to adjust that setting?
Couldn't you simply include the path when you include the file?
i have many files and having to setup the include path on each page is quite annoying.
i would like to be able to just set the include path as I can developing locally.

regardless of that, I am just curious as to whether it is possible to setup the include path when executing php pages on extel.

thanks
coco

cocoboy
Posts: 7
Joined: Fri Nov 17, 2006 10:56 pm

Re: Setting include path for PHP

Post by cocoboy » Sat Mar 07, 2009 1:23 am

I found a solution

<?php
require_once (realpath(dirname(__FILE__).'/../file.php'));
...
?>

so when I include this in another file which resides in another directory the require will work as expected.

coco

JasonM

Re: Setting include path for PHP

Post by JasonM » Sat Mar 07, 2009 1:42 am

I would also suggest perhaps a site global include file - I would typically include common functions in this file, and include it on pages.

You could then set the include path in that file, perhaps using ini_set.

Post Reply