like_escape

函式
like_escape ( $text )
引數
  • (string) $text The text to be escaped.
    Required:
返回值
  • (string) text, safe for inclusion in LIKE query.
相關
  • wpdb::esc_like()
定義位置
相關方法
js_escapetag_escapeattribute_escapelink_pagesnormalize_whitespace
引入
2.5.0
棄用
4.0.0

like_escape: 這是WordPress中的一個函式,用於轉義字串中的特殊字元,以便在MySQL LIKE查詢中使用。它可以用來確保一個包含特殊字元的搜尋查詢不會在MySQL資料庫中引起語法錯誤。

以前用於在搜尋DB之前轉義字串。它的記錄很差,而且從未像描述的那樣工作。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function like_escape($text) {
_deprecated_function( __FUNCTION__, '4.0.0', 'wpdb::esc_like()' );
return str_replace( array( "%", "_" ), array( "\%", "\_" ), $text );
}
function like_escape($text) { _deprecated_function( __FUNCTION__, '4.0.0', 'wpdb::esc_like()' ); return str_replace( array( "%", "_" ), array( "\%", "\_" ), $text ); }
function like_escape($text) {
	_deprecated_function( __FUNCTION__, '4.0.0', 'wpdb::esc_like()' );
	return str_replace( array( "%", "_" ), array( "\%", "\_" ), $text );
}

常見問題

FAQs
檢視更多 >