phpphp-ini

How to change a 'php.ini' setting in a PHP file


I am installing vtiger6 on a client's server. I don't have access to the php.ini file. I have tried to change some php.ini setting through my index.php file. Some settings work fine:

ini_set('max_execution_time', 600);
ini_set('log_errors', 'off');

But I am not able to set up the following:

ini_set('error_reporting', 'E_WARNING ^ E_NOTICE ^ E_DEPRECATED');
ini_set('allow_call_time_pass_reference', '1');

And also I need to change the following too. I don't know whether this is right or not.

ini_set('max_file_uploads', 300);
ini_set('memory_limit', '240M');
ini_set('max_input_time ', 600);

Solution

  • The reason why error_reporting did work not is you set its value to the following string. 'E_WARNING ^ E_NOTICE ^ E_DEPRECATED'. But it should not be a string. E_* values are PHP constants and should be used outside quotes like:

    ini_set('error_reporting', E_WARNING ^ E_NOTICE ^ E_DEPRECATED);
    

    Also you are using binary XOR (^) between these constants, which is unusual. The suggested value for a production environments is to use E_ALL alone, for debugging. If you want all errors except E_DEPRECATED, you can use E_ALL & ~E_DEPRECATED.

    Some PHP settings cannot be changed with ini_set. You can check the PHP documentation for which variables allow setting on the file level. For example, max_file_uploads is only changeable from the php.ini file (documentation).