首頁  >  文章  >  後端開發  >  php对表单内容进行处理_PHP教程

php对表单内容进行处理_PHP教程

WBOY
WBOY原創
2016-07-13 10:22:26834瀏覽

php对表单内容进行处理

/**
	 * 过滤HTML内容后返回
	 *
	 * @param      $string
	 * @param bool $html
	 *
	 * @return array|string
	 */
	public static function safeOutput($string, $html = false) {
		if (!$html)
			$string = strip_tags($string);

		return @Tools::htmlentitiesUTF8($string, ENT_QUOTES);
	}

	public static function htmlentitiesUTF8($string, $type = ENT_QUOTES) {
		if (is_array($string))
			return array_map(array('Tools', 'htmlentitiesUTF8'), $string);

		return htmlentities((string)$string, $type, 'utf-8');
	}

	public static function htmlentitiesDecodeUTF8($string) {
		if (is_array($string))
			return array_map(array('Tools', 'htmlentitiesDecodeUTF8'), $string);

		return html_entity_decode((string)$string, ENT_QUOTES, 'utf-8');
	}

	/**
	 * 对POST内容进行处理
	 *
	 * @return array
	 */
	public static function safePostVars() {
		if (!is_array($_POST))
			return array();
		$_POST = array_map(array('Tools', 'htmlentitiesUTF8'), $_POST);
	}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/847857.htmlTechArticlephp对表单内容进行处理 /** * 过滤HTML内容后返回 * * @param $string * @param bool $html * * @return array|string */public static function safeOutput($string, $html =...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn