What is the use of ini_set() in PHP?


PHP allows the user to modify some of its settings mentioned in php.ini using ini_set(). This function requires two string arguments. The first one is the name of the setting to be modified and the second one is the new value to be assigned to it.

Parameters

var name

Not all the available options can be changed using ini_set(). There is a list of all available options in the appendix.

new value

The new value for the option.

Example

<?php
   ini_set('display_errors', '1');
?>

Given the line of code will enable the display_error setting for the script if it’s disabled. We need to put the above statement, at the top of the script so that, the setting remains enabled till the end. Also, the values set via ini_set() are applicable, only to the current script. Thereafter, PHP will start using the original values from php.ini.

Updated on: 29-Jun-2020

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements