Introduction: This is a detailed page on how to use ini_set and ini_get () in PHP. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 330422 'rolling = 'no'>
This article is reproduced in PHP configuration functions. One function is used to set some variable values in PHP. ini. It is the PHP ini_set function that we will introduce to you today. The PHP ini_set function is the value in the setting option. It takes effect after the function is executed and expires when the script ends. Not all options can be changed to function settings. You can set specific values to view the list in the manual. You can set the option value in PHP. ini. For example, the display_error option is disabled, but you want to displayProgramTo facilitate program debugging, you can use the PHP ini_set function: ini_set ("display_errors", "on "); the program on your page will display the error information, and you can also use error_reporting to set the displayed error information level. If you need to increase the script execution time, you can set: ini_set ("max_execution_time", "180"); then, the script execution time is changed from 30 seconds to 180 seconds by default. Of course, you can also set it using set_time_limit. In fact, if you combine the PHP ini_set function with ini_get, it is very good. For example, if you want to add your own include file path to the configuration file, but you have the permission to change PHP. INI, you can combine two functions: ini_set ('include _ path', ini_get ('include _ path '). ':/your_include_dir:'); functions in PHP have different functions. flexible use of these functions can play a major role in this language. The PHP configuration function ini_get () can be used by many people to obtain the value of an option in the configuration file. If it is true, 1 is returned. If it is false, 0 is returned, returns the string.
For example, in the manual:
<? PHP
/* Our PHP. ini contains the following settings:
Display_errors = on
Register_globals = off
Post_max_size = 8 m
*/
Echo
'Display _ errors = '. ini_get ('display _ errors'). ""; // whether the Display error is enabled
Echo
'Register _ globals = '. ini_get ('register _ globals'). ""; // whether the global variable is enabled
Echo 'Post _ max_size = '. ini_get ('Post _ max_size'). ""; // maximum file size that can be submitted
Echo 'Post _ max_size + 1 = '. (ini_get ('Post _ max_size') + 1). "";
?>
Output:
Display_errors = 1
Register_globals = 0
Post_max_size = 8 m
Post_max_size + 1 = 9
The PHP configuration function ini_get () is mainly used to obtain the configuration file, which facilitates many operations. For example, if you want to filter strings, but do not know whether magic_quotes_gpc is enabled, you can write a function like this:
/* String filter function */
Function stringfilter ($ Str)
{
If
(Ini_get ('Magic _ quotes_gpc )')
{
Return $ STR;
} Else
{
Return
Addslashes ($ Str );
}
}
Of course, if you cannot know whether your global variables are enabled, you can also customize the following functions:
/* Variable detection function */
Function getgetvar ($ var)
{
If (ini_set ('register _ gobals '))
{
Return $ var;
} Else {
Return $ _ Get ['var'];
}
}
Of course, you can use the PHP configuration function ini_get () for many purposes.
"How to Use ini_set and ini_get () in PHP"
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/330422.html pageno: 11.