WordPress at a glance
function is not described

wpdb::_real_escape() public WP 2.8.0

Real escape, using mysqli_real_escape_string() or mysql_real_escape_string().

{} It's a method of the class: wpdb{}

No Hooks.

Return

String. Escaped string.

Usage

global $wpdb;
$wpdb->_real_escape( $string );
$string(string) (required)
String to escape.

Notes

  • See: mysqli_real_escape_string()
  • See: mysql_real_escape_string()

Changelog

Since 2.8.0 Introduced.

Code of wpdb::_real_escape() WP 5.5.1

<?php
function _real_escape( $string ) {
	if ( $this->dbh ) {
		if ( $this->use_mysqli ) {
			$escaped = mysqli_real_escape_string( $this->dbh, $string );
		} else {
			$escaped = mysql_real_escape_string( $string, $this->dbh );
		}
	} else {
		$class = get_class( $this );
		if ( function_exists( '__' ) ) {
			/* translators: %s: Database access abstraction class, usually wpdb or a class extending wpdb. */
			_doing_it_wrong( $class, sprintf( __( '%s must set a database connection for use with escaping.' ), $class ), '3.6.0' );
		} else {
			_doing_it_wrong( $class, sprintf( '%s must set a database connection for use with escaping.', $class ), '3.6.0' );
		}
		$escaped = addslashes( $string );
	}

	return $this->add_placeholder_escape( $escaped );
}