Jump to content

PHP Include Path on hosted service?


doni49

Recommended Posts

I use a webhost for my websites.  I have one main domain with 2 add-on domains.  I've had this service for about a year.

Since that time, I've had three seperate PHP.ini files--one in the public_html folder for each domain.  The purpose of each PHP.ini file is that it sets the include search path for each domain.  But now all of a sudden, the PHP.ini file stopped loading therefore the include path has not been set as it's supposed to be and has been for the past year.

When I asked my web host about it, I was informed that it should NEVER have worked this way and they don't allow individuals to use their own PHP.ini files.

Anyone have any ideas on how I can set the include path for MY domains on a hosted account?  I don't want to have to specify the whole path with every include statement but I want to keep the include files seperate for security reasons.

Thanks.

EDIT:  Ok I've found something that SEEMS like it should be what I need.  But it's not working as expected.

First here's a link to a tutorial I found on this site.  www.phpfreaks.com/tutorials/10/0.php  There are three examples shown in the tutorial, I'm looking at the THIRD example. 

The following is what I put in my .htaccess file (I do have rights to keep my own .htaccess file):
[b]php_value include_path .:[color=red]/home2/username/includefolder1[/color]:[color=red]/home2/username/public_html/php[/color]:/usr/lib/php:/usr/local/lib/php
[/b]
When I try to load a web page with this line there, I get an internal server error (500).  When I take this line out, it just tells me that it can't find my include files.

I need it to look 1st in the same folder as the page that's loading.  Then in the two folders that are RED above.  Then to the default location as provided by the server's default settings.  The following is the default include_path before I make my changes (as told by [i]phpinfo()[/i]).

[b].:/usr/lib/php:/usr/local/lib/php
[/b]
Thanks again!
Link to comment
Share on other sites

Try surrounding it in quotes:
[code]php_value include_path ".:/home2/username/includefolder1:/home2/username/public_html/php:/usr/lib/php:/usr/local/lib/php"
[/code]
Also make sure you have changed [b]/home2/username/includefolder1[/b] and [b]/home2/username/public_html/php:/[/b] to the correct location. If it still doesnt work ask you hosts whether you can use the php_value directive in a .htaccess file.

If that doesnt work. Then you'll define the location of the files in your script. You can create a constent called INC_PATH, this constant will then holds the path to your include folder, where all you include files are located
[code=php:0]define('INC_PATH', '/path/to/my/include/folder/');[/code]


Then when you want to include a file that is in your include folder you'll use the following:
[code=php:0]include INC_PATH . 'filetoinclude.php';[/code]


That is the only otherway if you host doesnt allow you to use your own php.ini and has disabled the php_value directive in the .htaccess file.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.