When a php directive can be set with ini_set() or in .htaccess, is there any consensus on which is preferrable and why?
The obvious difference is that ini_set() allows control per script, whereas .htaccess allows control per directory, but are there other differences that should be taken into consideration?
Thanks,
Drew
ini_set() vs .htaccess
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: ini_set() vs .htaccess
I think it is really just the practical differences. You can call ini_set() programmatically, whereas you have to edit a file to change .htaccess. There are some settings that need set before the script runs -- so php.ini or .htaccess would be required.
(#10850)
Re: ini_set() vs .htaccess
I've read that some programmers prefer to do as much as possible in their actual scripts, rather than in .htaccess, even if that means calling ini_set() at the beginning of all the scripts in a directory, rather than just using an .htaccess file for the directory. Is this just a quirky personal preference of some programmers? Or are there many web hosts that disallow .htaccess files, such that a web application is more useful in shared hosting situations if it does not require an .htaccess file?
Cheers,
Drew
Cheers,
Drew
Re: ini_set() vs .htaccess
Duplicating a call to ini_set() is a waste of time in my opinion. If you've got a setting you know will be universal across an application/directory, put it in a central file - whether that's an .htaccess file or a central config.inc file doesn't matter. Calling ini_set() at the top of every file is very inefficient & hell to change.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.