backslashit()WP 0.71

Adds backslashes before letters and before a number at the start of a string.

No Hooks.

Return

String. String with backslashes inserted.

Usage

backslashit( $string );
$string(string) (required)
Value to which backslashes will be added.

Examples

0

#1 Add escaping slashes to the line characters.

$string = "321!hello&<-->ещеLetters&123";

echo backslashit( $string );

// we get: 1!\h\e\l\l\o&<-->еще\L\e\t\t\e\r\s&123

Changelog

Since 0.71 Introduced.

Code of backslashit() WP 6.0.1

function backslashit( $string ) {
	if ( isset( $string[0] ) && $string[0] >= '0' && $string[0] <= '9' ) {
		$string = '\\\\' . $string;
	}
	return addcslashes( $string, 'A..Za..z' );
}