Copy CodeThe code is as follows:
Define constannts for input reading
Define (' Input_get ', 0x0101);
Define (' Input_post ', 0x0102);
Define (' INPUT_GPC ', 0x0103);
/**
* Read input value and convert it for internal use
* Performs stripslashes () and CharSet conversion if necessary
*
* @param string Field name to read
* @param int Source to get value from (GPC)
* @param boolean Allow HTML tags in field value
* @param string Charset to convert into
* @return String Field value or NULL if not available
*/
function Get_input_value ($fname, $source, $allow _html=false, $charset =null) {
$value = NULL;
if ($source = = Input_get && isset ($_get[$fname]))
$value = $_get[$fname];
else if ($source = = Input_post && isset ($_post[$fname]))
$value = $_post[$fname];
else if ($source = = INPUT_GPC) {
if (Isset ($_post[$fname]))
$value = $_post[$fname];
else if (Isset ($_get[$fname]))
$value = $_get[$fname];
else if (Isset ($_cookie[$fname]))
$value = $_cookie[$fname];
}
if (empty ($value))
return $value;
Strip single Quotes if Magic_quotes_sybase is enabled
if (Ini_get (' magic_quotes_sybase '))
$value = Str_replace ("'" "," ' ", $value);
Strip slashes if magic_quotes enabled
else if (GET_MAGIC_QUOTES_GPC () | | | get_magic_quotes_runtime ())
$value = Stripslashes ($value);
Remove HTML tags if not allowed
if (! $allow _html)
$value = Strip_tags ($value);
Convert to Internal charset
return $value;
}
Usage: get_input_value (' _uid ', input_get)
http://www.bkjia.com/PHPjc/325512.html www.bkjia.com true http://www.bkjia.com/PHPjc/325512.html techarticle Copy the code as follows://define constannts for input reading define (' Input_get ', 0x0101); define (' Input_post ', 0x0102); define (' I NPUT_GPC ', 0x0103); /** * Read input value and ...