backslashit()
Adds a backslash (\) before letters and before digits at the beginning of the string.
No Hooks.
Returns
String. the formatted string.
Usage
<?php backslashit( $string ) ?>
- $string(string) (required)
- The string to be formatted.
Examples
#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. |
backslashit() backslashit code WP 6.9.1
function backslashit( $value ) {
if ( isset( $value[0] ) && $value[0] >= '0' && $value[0] <= '9' ) {
$value = '\\\\' . $value;
}
return addcslashes( $value, 'A..Za..z' );
}