backslashit

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

Description

(string) backslashit( (string) $string ); 

Returns (string)

String with backslashes inserted.

Parameters (1)

0. $string (string)
Value to which backslashes will be added.

Usage

  1. if ( !function_exists( 'backslashit' ) ) { 
  2. require_once ABSPATH . WPINC . '/formatting.php'; 
  3.  
  4. // Value to which backslashes will be added. 
  5. $string = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = backslashit($string); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/formatting.php  
  1. function backslashit( $string ) { 
  2. if ( isset( $string[0] ) && $string[0] >= '0' && $string[0] <= '9' ) 
  3. $string = '\\\\' . $string; 
  4. return addcslashes( $string, 'A..Za..z' );