Elastica\JSON::stringify PHP Method

stringify() public static method

Convert input to JSON string with standard options.
public static stringify ( $args ) : string
return string Valid JSON representation of $input
    public static function stringify($args)
    {
        // extract arguments
        $args = func_get_args();
        // run encode and output
        $string = call_user_func_array('json_encode', $args);
        // turn errors into exceptions for easier catching
        if ($error = self::getJsonLastErrorMsg()) {
            throw new JSONParseException($error);
        }
        // output
        return $string;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Log a message.
  *
  * @param mixed  $level
  * @param string $message
  * @param array  $context
  *
  * @return null|void
  */
 public function log($level, $message, array $context = array())
 {
     $context['error_message'] = $message;
     $this->_lastMessage = JSON::stringify($context);
     if (!empty($this->_log) && is_string($this->_log)) {
         error_log($this->_lastMessage . PHP_EOL, 3, $this->_log);
     } else {
         error_log($this->_lastMessage);
     }
 }
All Usage Examples Of Elastica\JSON::stringify