Example #1
0
/**
 * 转义html字符
 *
 * @param string|array $var
 */
function fhtmlspecialchars($var) {
	if (is_array ( $var )) {
		foreach ( $var as $k => $v ) {
			$var [$k] = fhtmlspecialchars ( $v );
		}
	} else if (is_string ( $var )) {
		$var = htmlspecialchars ( $var, ENT_COMPAT, 'UTF-8' );
	}
	return $var;
}
Example #2
0
	/**
     * 获取参数值
     * @param string $name http参数key
     * @param bool $htmQuotes 是否转义html
     * @param string $tags 允许保留到标签,all 为去全部
     * @return string | array
     */
	public static function get ($name = null, $default =null, $htmQuotes = true, $tags = null) {
        if (!$name) return self::$DATA;
        if (!isset(self::$DATA[$name])) {
        	return $default;
        }
        $str = self::$DATA[$name];
        if ($htmQuotes) {
        	$str = fhtmlspecialchars($str);
        }
        if ($tags !== 'all') {
        	$str = fstripTags($str, $tags);
        }
        return $str;
    }