wp_specialchars

函式
wp_specialchars ( $text, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false )
引數
  • (string) $text Text to escape.
    Required:
  • (string) $quote_style Unused.
    Required:
    Default: ENT_NOQUOTES
  • (false|string) $charset Unused.
    Required:
    Default: false
  • (false) $double_encode Whether to double encode. Unused.
    Required:
    Default: false
返回值
  • (string) Escaped `$text`.
相關
  • esc_html()
定義位置
相關方法
_wp_specialcharswp_specialchars_decodewp_cache_reset_canonical_charsetwp_slash
引入
-
棄用
2.8.0

wp_specialchars: 這個函式對字串中的特殊字元進行編碼,以便在HTML中使用。它用於轉義任何在HTML中具有特殊意義的字元,如<、>、&等,以確保內容在網頁中的正確顯示。

為HTML塊進行轉義。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_specialchars( $text, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
_deprecated_function( __FUNCTION__, '2.8.0', 'esc_html()' );
if ( func_num_args() > 1 ) { // Maintain back-compat for people passing additional arguments.
return _wp_specialchars( $text, $quote_style, $charset, $double_encode );
} else {
return esc_html( $text );
}
}
function wp_specialchars( $text, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { _deprecated_function( __FUNCTION__, '2.8.0', 'esc_html()' ); if ( func_num_args() > 1 ) { // Maintain back-compat for people passing additional arguments. return _wp_specialchars( $text, $quote_style, $charset, $double_encode ); } else { return esc_html( $text ); } }
function wp_specialchars( $text, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
	_deprecated_function( __FUNCTION__, '2.8.0', 'esc_html()' );
	if ( func_num_args() > 1 ) { // Maintain back-compat for people passing additional arguments.
		return _wp_specialchars( $text, $quote_style, $charset, $double_encode );
	} else {
		return esc_html( $text );
	}
}

常見問題

FAQs
檢視更多 >