5

I don't have access to global php.ini file since I am running my application on shared hosting and now what happens is I need to put my php.ini file in every directory to use the settings. But I am wondering whether there is a way to override the global php.ini file in my root directory for every sub folders instead of putting the php.ini file inside of every and each folder which isn't a good practice for further times.

If you are asking which specific option I need to change is auto_prepend_file

Tarik
  • 79,711
  • 83
  • 236
  • 349

2 Answers2

9

Yes! Not all php.ini options can be set, but many can be changed through .htaccess files, or the ini_set function, etc. See these pages.

imm
  • 5,837
  • 1
  • 26
  • 32
  • I cannot use .htaccess for that since it is in CGI mode so I am not allowed to use php_value stuff. – Tarik Oct 16 '11 at 02:23
5

For CGI/FastCGI use .user.ini files Docs. Works since PHP 5.3.

Some shared hosters allow as well to place php.ini files into the webroot directory or at some other place. Contact your hoster.

hakre
  • 193,403
  • 52
  • 435
  • 836
  • 1
    I just want to add that it wasn't immediately obvious to me that `.user.ini` is the default name of the file (configurable in php.ini as `user_ini.filename`), and not the __file extension__. So the name of your file should be `.user.ini` if you use the default. – trey-jones Feb 19 '15 at 18:18