The ini_set Function
The ini_set
function temporarily changes a PHP setting value.
The change is effective only during the execution of the current script.
The function accepts the setting name as the first parameter and the new value as the second.
Syntax
ini_set(string $option, string $value);
Example
Let's change the maximum script execution time to 30
seconds:
<?php
ini_set('max_execution_time', '30');
echo 'New timeout: ' . ini_get('max_execution_time');
?>
Code execution result:
'New timeout: 30'
Example
Let's enable displaying all errors:
<?php
ini_set('display_errors', '1');
ini_set('error_reporting', E_ALL);
?>
Example
Let's set a new directory for file uploads:
<?php
ini_set('upload_tmp_dir', '/custom/upload/path');
?>
See Also
-
the
ini_get
function,
which retrieves the current value of a setting