json_encode

The WordPress Core json encode function.

Description

json_encode( $string ); 

Parameters (1)

0. $string
The string.

Usage

  1. if ( !function_exists( 'json_encode' ) ) { 
  2. require_once ABSPATH . WPINC . '/compat.php'; 
  3.  
  4. // The string. 
  5. $string = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = json_encode($string); 
  9.  

Defined (2)

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

/wp-includes/compat.php  
  1. function json_encode( $string ) { 
  2. global $wp_json; 
  3.  
  4. if ( ! ( $wp_json instanceof Services_JSON ) ) { 
  5. require_once( ABSPATH . WPINC . '/class-json.php' ); 
  6. $wp_json = new Services_JSON(); 
  7.  
  8. return $wp_json->encodeUnsafe( $string ); 
/wp-admin/includes/noop.php  
  1. function json_encode() {}