Warning: This function has been deprecated. Use wpdb::esc_like() instead.

like_escape() WordPress Function

The like_escape() function is used to escape LIKE wildcard characters in a string for use in a SQL LIKE clause. This function is useful for ensuring that LIKE wildcard characters do not cause unexpected results when used in a SQL query.

like_escape( string $text ) #

Formerly used to escape strings before searching the DB. It was poorly documented and never worked as described.


Description

Top ↑

See also


Top ↑

Parameters

$text

(string)(Required)The text to be escaped.


Top ↑

Return

(string) text, safe for inclusion in LIKE query.


Top ↑

Source

File: wp-includes/deprecated.php

function like_escape($text) {
	_deprecated_function( __FUNCTION__, '4.0.0', 'wpdb::esc_like()' );
	return str_replace( array( "%", "_" ), array( "\\%", "\\_" ), $text );
}


Top ↑

Changelog

Changelog
VersionDescription
4.0.0Use wpdb::esc_like()
2.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More