Use this conditionally when $isHtml is true, and is
also running on PHP > = 5.4. Else return default 0
Change-Id: Ief775720a99d1a305c3f9f4ba7cc04eb96817fb3
* @return string
*/
public static function encode( $value, $isHtml = false ) {
- if ( !function_exists( 'json_encode' ) || $isHtml ) {
+ if ( !function_exists( 'json_encode' ) || ( $isHtml && version_compare( PHP_VERSION, '5.4.0', '<' ) ) ) {
$json = new Services_JSON();
return $json->encode( $value, $isHtml );
} else {
- return json_encode( $value );
+ return json_encode( $value, $isHtml ? JSON_PRETTY_PRINT : 0 );
}
}