Forum Moderators: coopster

Message Too Old, No Replies

Automatically include a PHP file

include_path doesn't seem to be working

         

panic

5:25 pm on Sep 26, 2005 (gmt 0)

10+ Year Member



I've got a PHP file with custom functions that I commonly use. I want that file (functions.php) to be included every tiem PHP is executed.

I tried including the path in the php.ini as the include_path, but it doesn't seem to work. The error I'm getting is :

Fatal error: Call to undefined function

I'm running this on Win32 (Windows XP), with this PHP build :

PHP 5.0.5 (cli) (built: Sep 5 2005 15:54:44)

Any ideas as to what I'm doing wrong?

grandpa

8:33 pm on Sep 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It sounds like you still have a path problem. I could be in your php.ini or in how you define your include statement in the script.

FWIW, I can't alter the php.ini file on my web server. But I can still alter the path with ini_set.

ini_set("include_path", "/home/domain/public_html/path/php/include");

Then in the php scripts that I run in the path/php directory I have altered the include statements to read
include ("include/include_file.inc");

Works a charm. Be aware that changing the path in this manner (using ini_set) only works for the script in which the change is made. In other words, I had to make this change to every script in the path/php directory.

panic

8:49 pm on Sep 26, 2005 (gmt 0)

10+ Year Member



The reason I'm trying to include it every time PHP is executed is to prevent me from adding the include("/path/to/functions.php"); on each PHP file.

When I put the include function manually into the script, it works fine. When I add the function to the script, the function works just fine.

I've done this on my old Windows box, but I can't remember what I did , and that machine is long gone.

grandpa

8:56 pm on Sep 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



All I can suggest is that you have more than one php.ini on the machine, and either you've changed the wrong one, or the path in php.ini is incorrect.

Check your system path for php.ini first.

Start->Run->cmd
then type path

Chances are good that a Windows directory will appear before a PHP directory, and that there is a php.ini lurking in that Windows directory.

jatar_k

2:43 am on Sep 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



maybe try this setting in php.ini

[php.net...]

panic

3:38 pm on Sep 27, 2005 (gmt 0)

10+ Year Member



That's exactly what I was looking for. Thanks jatar :)