Changing the php.ini that is loaded

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Changing the php.ini that is loaded

Post by malcolmboston »

Im currently having problems with my web server as it is not loading the expected php.ini

im wanting to know if theres anyway of specifying the php.ini that is loaded everytime

short and sweet

also is there anywhere that specifies which one is loaded each time?
i dont think there is mind

Thanks
Mal
mmanders
Forum Newbie
Posts: 23
Joined: Sun Jan 16, 2005 7:13 pm

Post by mmanders »

I'm a relative newbie at PHP so this may or may not help. It depends why specifically you need to load a particular php.in file.

If you want to override certain php.ini directives like say include_path, there are functions that let you do this, however they generally only change the directive for the duration of the script.

Lets say you wanted a different include_dir to the one php.in sets out, at the top of your script use

Code: Select all

$path = 'new_path';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
This will set the include_path for the script to be the existing path as well as the new path you specify - there are probably other functions similar to this for setting different php.ini directives.

Hope this helps :-S
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

basically i needed it because it was loading a different version of PHP.ini that i wanted it too
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

as mentionned in the manual, PHPRC environment variable is easiest ;)
Post Reply