當前位置: 首頁>>代碼示例>>PHP>>正文


PHP core::json_encode方法代碼示例

本文整理匯總了PHP中core::json_encode方法的典型用法代碼示例。如果您正苦於以下問題:PHP core::json_encode方法的具體用法?PHP core::json_encode怎麽用?PHP core::json_encode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在core的用法示例。


在下文中一共展示了core::json_encode方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: message

 public function message($msg, $jumpurl = '')
 {
     if (core::gpc('ajax')) {
         $arr = array('servererror' => '', 'status' => 1, 'message' => $msg);
         echo core::json_encode($arr);
         exit;
     } else {
         echo $msg;
         exit;
     }
 }
開發者ID:phpdn,項目名稱:xiunophp,代碼行數:11,代碼來源:base_control.class.php

示例2: display

 public function display($file, $json = array())
 {
     if (!core::gpc('ajax', 'R')) {
         extract($this->vars, EXTR_SKIP);
         include $this->gettpl($file);
         // json 格式,約定為格式。
     } else {
         ob_start();
         extract($this->vars, EXTR_SKIP);
         include $this->gettpl($file);
         $body = ob_get_contents();
         ob_end_clean();
         $json = array('servererror' => '', 'status' => 1, 'message' => array('width' => 400, 'height' => 300, 'pos' => 'center', 'title' => '默認窗口標題', 'body' => ''));
         $json['message'] = array_merge($json['message'], $this->json);
         $this->fetch_json_header($body, $json['message']);
         $json['message']['body'] = $body;
         echo core::json_encode($json);
     }
 }
開發者ID:phpdn,項目名稱:xiunophp,代碼行數:19,代碼來源:template.class.php

示例3: to_json

 public static function to_json($e)
 {
     if (DEBUG) {
         $arr = self::format_exception($e);
         $backinfo = '';
         foreach ($arr['backtracelist'] as $v) {
             $backinfo .= "{$v['file']} [{$v['line']}] : {$v['class']}{$v['type']}{$v['function']}({$v['args']})\r\n";
         }
         $s = "{$arr['message']}\r\n File: {$arr['file']} [{$arr['line']}] \r\n \r\n {$backinfo}";
         $s = str_replace(array('&nbsp;', '<br />', '&gt;', '&lt;'), array(' ', "\r\n", '>', '<'), $s);
         $s = preg_replace('#[\\r\\n]+#', "\n", $s);
     } else {
         $s = $e->getMessage();
     }
     $s = preg_replace('# \\S*[/\\\\](.+?\\.php)#', ' \\1', $s);
     //$s = preg_replace('#[\\x80-\\xff]{2}#', '?', $s);// 替換掉 gbk, 否則 json_encode 會報錯!
     $arr = array('servererror' => $s);
     return core::json_encode($arr);
 }
開發者ID:phpdn,項目名稱:xiunophp,代碼行數:19,代碼來源:xn_exception.class.php

示例4: exception_handle

 public static function exception_handle($e)
 {
     // 避免死循環
     DEBUG && ($_SERVER['exception'] = 1);
     core::ob_clean();
     log::write($e->getMessage() . ' File: ' . $e->getFile() . ' [' . $e->getLine() . ']');
     $s = '';
     if (DEBUG) {
         try {
             if (self::gpc('ajax', 'R')) {
                 $s = xn_exception::to_json($e);
             } else {
                 //!core::is_cmd() && header('Content-Type: text/html; charset=UTF-8');
                 $s = xn_exception::to_html($e);
             }
         } catch (Exception $e) {
             $s = get_class($e) . " thrown within the exception handler. Message: " . $e->getMessage() . " on line " . $e->getLine();
         }
     } else {
         if (self::gpc('ajax', 'R')) {
             $s = core::json_encode(array('servererror' => $e->getMessage()));
         } else {
             $s = $e->getMessage();
         }
     }
     echo $s;
     exit;
 }
開發者ID:phpdn,項目名稱:xiunophp,代碼行數:28,代碼來源:core.class.php

示例5: error_handler

 /**
  * Custom error handler.
  *
  * Catches all errors (not exceptions) and creates an ErrorException.
  * ErrorException then can caught by Yaf\ErrorController.
  *
  * @param integer $errno the error number.
  * @param string $errstr the error message.
  * @param string $errfile the file where error occured.
  * @param integer $errline the line of the file where error occured.
  *
  * @throws ErrorException
  */
 static function error_handler($errno, $errstr, $errfile, $errline)
 {
     // 防止死循環
     $errortype = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice');
     $errnostr = isset($errortype[$errno]) ? $errortype[$errno] : 'Unknonw';
     // 運行時致命錯誤,直接退出。並且 debug_backtrace()
     $s = "[{$errnostr}] : {$errstr} in File {$errfile}, Line: {$errline}";
     // 拋出異常,記錄到日誌
     //echo $errstr;
     if (DEBUG && empty($_SERVER['exception'])) {
         throw new Exception($s);
     } else {
         log::write($s . date('Y-M-D H:i:s', $_SERVER['time']));
         //$s = preg_replace('# \S*[/\\\\](.+?\.php)#', ' \\1', $s);
         if (core::gpc('ajax', 'R')) {
             core::ob_clean();
             //$s = preg_replace('#[\\x80-\\xff]{2}#', '?', $s);// 替換掉 gbk, 否則 json_encode 會報錯!
             // 判斷錯誤級別,決定是否退出。
             if ($errno != E_NOTICE && $errno != E_USER_ERROR && $errno != E_USER_NOTICE && $errno != E_USER_WARNING) {
                 $s = core::json_encode(array('servererror' => $s));
                 throw new Exception($s);
                 exit;
             } else {
                 $_SERVER['notice_error'] .= $s;
                 // 繼續執行。
             }
         } else {
             //echo $s;
             // 繼續執行。
         }
     }
     return 0;
 }
開發者ID:290329416,項目名稱:guahao,代碼行數:46,代碼來源:Bootstrap.php

示例6: update

 public function update($key, $data)
 {
     return $this->saekv->set($key, core::json_encode($data));
 }
開發者ID:phpdn,項目名稱:xiunophp,代碼行數:4,代碼來源:db_saekv.class.php


注:本文中的core::json_encode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。