Search code examples
phptypesparametersversionini-set

PHP - ini_set() expects parameter 2 to be string, integer given


I have this part of code:

...
ini_set('max_execution_time', 300);
...

Until now it worked. Now i am getting this error:

ini_set() expects parameter 2 to be string, integer given

What has changed? Can it be caused by PHP version?


Solution

  • PHP actually expects both parameters of ini_set() to be of type string and returns a string:

    ini_set ( string $varname , string $newvalue ) : string

    You can find this in the PHP manual on ini_set.

    If you have set strict_types with

    declare(strict_types=1);
    

    then you will have to change your ini_set() values to

    ini_set('max_execution_time', '300');