PHP Error Handling Setting Configuration Variables - Web Development and Design | Tutorial for Java, PHP, HTML, Javascript PHP Error Handling Setting Configuration Variables - Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Tuesday, July 2, 2019

PHP Error Handling Setting Configuration Variables

PHP Error Handling



Setting Configuration Variables


Problem

You want to change the value of a PHP configuration setting.

Solution

Use ini_set():

       // add a directory to the include path
       ini_set('include_path', ini_get('include_path') . ':/home/fezzik/php');

Discussion

Configuration variables are not permanently changed by ini_set(). The new value lasts only for the duration of the request in which ini_set() is called. To make a persistent modification, alter the values stored in the php.ini file.

It isn’t meaningful to alter certain variables, such as asp_tags, because by the time you call ini_set() to modify the setting, it’s too late to change the behavior the setting affects. If a variable can’t be changed, ini_set() returns false.

However, it is useful to alter configuration variables in certain pages. For example, if you’re running a script from the command line, set html_errors to off.

To reset a variable back to its original setting, use ini_restore():

       ini_restore('sendmail_from'); // go back to the default value


No comments:

Post a Comment

Post Top Ad