PHP's configuration function is a few ini_* functions, mainly for the operation of the configuration file, in fact, four functions: Ini_get, Ini_set, Ini_get_all, Ini_restore. The most useful thing about personal feeling is ini_set and ini_get.
* Ini_get (): Gets the option value of the configuration file
This function is believed by many people to get the value of one of the options in the configuration file, return 1 if the value is true, and return 0 if the value is false, and the string will return the string.
For example in the manual:
/*
Our php.ini contains the following settings:
Display_errors = On
Register_globals = Off
Post_max_size = 8M
*/
echo ' display_errors = '. Ini_get (' display_errors '). "\ n"; Show whether the error is turned on
echo ' register_globals = '. Ini_get (' register_globals '). "\ n";/whether the global variable is open
echo ' post_max_size = '. Ini_get (' Post_max_size '). "\ n";/maximum file size to submit
echo ' post_max_size+1 = '. (Ini_get (' post_max_size ') +1). "\ n";
? > |
Output:
Display_errors = 1
register_globals = 0
Post_max_size = 8M
Post_max_size+1 = 9 |
This function is mainly to get the configuration file, you can easily do a lot of operations. For example, you want to manipulate string filtering, but it's not clear if MAGIC_QUOTES_GPC is open, so 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 don't know if your global variable is open, you can also customize such a function:
/* Variable detection function * *
function Getgetvar ($var)
{
if (Ini_set (' register_gobals ')) {
return $var;
} else {
Return $_get[' var '];
}
} |
Of course, you can do a lot of use, your own slowly experience.