* Thus wrote A. Lanza:
> In fact, i'm not changing the include_path in my code, just uncommented
> the line in php.ini configuration file.
> 
> Do i have to set include_path in code? Where in code should i put that
> piece of code setting include_path? Is there any simple way to include
> files using relative paths from the ones where main scripts are?
> 
> I have /var/www/html/project, where i put my scripts. includes directory
> is under that path. I want to put all my include files in there. I
> guessed that including files like this, include 'includes/db.inc', would
> work, since include_path is set to "." in php.ini, but it does not.

>From my understanding you have:

php.ini:include_path = ".:/php/includes";

The scripts you want to include are located in:
  /var/www/html/project/includes

All you have to do is set your include_path in php.ini:
  include_path = "/var/www/html/project/includes:.:/php/includes";

restart webserver.

Then to include the file you want, include it relative to the
include_path:

  include('db.inc');

That will try and find a file in these locations in order:
  /var/www/html/projects/include/db.inc
  ./db.inc
  /php/includes/db.inc

And will use the first one found.

I would  not suggest using ini_set() inside you're scripts to
adjust your paths.



Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to