Example #1
0
 public static function getRetJson($errorCode, $errorMessage = '', $data = NULL, $callback = NULL)
 {
     if (empty($errorMessage)) {
         $errorMessage = self::getMsg($errorCode);
     }
     $jsonPrototype = array('error_code' => $errorCode, 'error_message' => $errorMessage);
     if (!empty($data)) {
         $jsonPrototype += is_string($data) ? str_replace(array("\r", "\n", "\t"), '', $data) : $data;
     }
     //对变量进行 JSON 编码
     $json = Core_Fun::jsonEncode($jsonPrototype);
     return $json;
 }