27.3. How to change PHP parameters when you don't have access to php.ini

Unless you have your own “root” server, you are most probably sharing the same hardware with a few thousand other so-called “virtual” domains. For this reason, it is all too natural that your ISP will deny you access to the system-wide php.ini file (usually located under /etc). Whatever value you enter there, is going to affect all the virtual domains running on that machine!

But what to do if you find out that you must change a setting and you are told to change it in php.ini? Fortunately, there is an alternative way - and once again the .htaccess file (see Section 25.4) comes to your rescue:

To set register_globals to off (a good idea from a security point of view, see Section 23.4.2), for example, add

php_flag register_globals off

to the .htaccess file in the PHP-Nuke root directory.

To set magic_quotes to off (a bad idea from a security point of view, see Section 23.4.2), you can add the following line to the .htaccess file in the PHP-Nuke root directory:

php_flag magic_quotes_gpc off

To set "display_errors" to off, add:

php_flag display_errors off

while to set the include path (see Section 3.9.10), you can add

php_value include_path “your/include/path/here”

If you get a memory limit error like:

Fatal error: Allowed memory size of 8388608 bytes exhausted 
(tried to allocate 67584 bytes) in xxx/xxxxxxx/xxxxx

then you can try to increase allocated memory with

php_value memory_limit “16M”

although you will probably not achieve the desired result, due to restrictions that your ISP has set in place.

To change the maximum execution time limit of your PHP scripts, add:

php_value max_execution_time 60

This will set the time limit to 60 seconds. But if you are not allowed to change php.ini, it is doudtful that you will be allowed to change the value of max_execution_time in a .htaccess file. If you can do it, however, then the .htaccess method gives you the flexibility to set different time limits in different directories - and thus different scripts that reside therein. See also Page genration time too long.

As you have guessed by now , the general syntax is:

php_value PHP-variable value