当前位置: 首页>>代码示例>>PHP>>正文


PHP json函数代码示例

本文整理汇总了PHP中json函数的典型用法代码示例。如果您正苦于以下问题:PHP json函数的具体用法?PHP json怎么用?PHP json使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了json函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * @return \Response
  */
 public function update()
 {
     $this->passwordForm->validate(Input::all());
     $this->user()->password = Input::get('new_password');
     $this->user()->save();
     return json(trans('app.password_changed'));
 }
开发者ID:adriancatalinsv,项目名称:fiip,代码行数:10,代码来源:PasswordController.php

示例2: validateDemo

 /**
  * 验证演示
  *
  * @return \Slim\Http\Response
  */
 public function validateDemo()
 {
     $rules = ['username' => 'required', 'password' => 'required|confirmed', 'sex' => 'integer|in:1,0'];
     validate($this->request->post(), $rules);
     //以下是验证通过的情况下
     return json(['status' => 'validation passes.']);
 }
开发者ID:ziyanziyu,项目名称:rester,代码行数:12,代码来源:HomeController.php

示例3: ajax_check_code

 public function ajax_check_code()
 {
     $invite_code = $this->_get('invite_code');
     $org_code = $this->_get('org_code');
     if (!$invite_code || !$org_code) {
         return;
     }
     $f['code'] = $invite_code;
     $f['org_code'] = $org_code;
     $invite_data = M("InviteCodes")->where($f)->find();
     // 如果存在,写对了,对bind++
     if ($invite_data) {
         $data['id'] = $invite_data['id'];
         $data['is_bind'] = $invite_data['is_bind'] + 1;
         M("InviteCodes")->save($data);
         $partner = M('Partners')->where(array('org_code' => $org_code))->find();
         if (!$partner) {
             $p_data['org_code'] = $org_code;
             $partner_id = M("Partners")->add($p_data);
         } else {
             $partner_id = $partner['id'];
         }
         json('check_code_callback(' . $partner_id . ',"' . $invite_data['org_name'] . '")', 'eval');
     } else {
         json('check_code_callback(0,"")', 'eval');
     }
 }
开发者ID:Germey,项目名称:yinxingapply,代码行数:27,代码来源:ValidationAction.class.php

示例4: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if (app()->environment('production')) {
         $title = 'Error';
         $description = 'Unknown error occurred :(';
         $statusCode = 400;
         if ($e instanceof ModelNotFoundException or $e instanceof NotFoundHttpException) {
             $title = trans('errors.not_found');
             $description = trans('errors.not_found_description');
             $statusCode = 404;
         }
         return response(view('errors.notice', ['title' => $title, 'description' => $description]), $e->getCode() ?: $statusCode);
     }
     if (is_api_request()) {
         $statusCode = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : $e->getCode();
         if ($e instanceof TokenExpiredException) {
             $message = 'token_expired';
         } elseif ($e instanceof TokenInvalidException) {
             $message = 'token_invalid';
         } elseif ($e instanceof JWTException) {
             $message = $e->getMessage() ?: 'could_not_create_token';
         } elseif ($e instanceof NotFoundHttpException or $e instanceof ModelNotFoundException) {
             $statusCode = 404;
             $message = $e->getMessage() ?: 'not_found';
         } elseif ($e instanceof MethodNotAllowedHttpException) {
             $message = $e->getMessage() ?: 'not_allowed';
         } elseif ($e instanceof HttpResponseException) {
             return $e->getResponse();
         } elseif ($e instanceof Exception) {
             $message = $e->getMessage() ?: 'Whoops~ Tell me what you did :(';
         }
         return json()->setStatusCode($statusCode ?: 400)->error($message);
     }
     return parent::render($request, $e);
 }
开发者ID:corean,项目名称:l5essential,代码行数:42,代码来源:Handler.php

示例5: get

 public function get()
 {
     $user = Auth::get();
     if ($user) {
         return json($user->newNotifications(), true);
     }
 }
开发者ID:fant0m,项目名称:VAII,代码行数:7,代码来源:NotificationController.php

示例6: forbiddenResponse

 /**
  * {@inheritDoc}
  */
 public function forbiddenResponse()
 {
     if (is_api_request()) {
         return json()->forbiddenError();
     }
     return response('Forbidden', 403);
 }
开发者ID:linuxssm,项目名称:l5essential,代码行数:10,代码来源:Request.php

示例7: delete

 public function delete()
 {
     $id = I('get.id');
     D('Message')->where('id=%d', $id)->delete();
     session('success', '删除留言成功');
     json(NULL, 'refresh');
 }
开发者ID:Germey,项目名称:SimpleCMS,代码行数:7,代码来源:MessageController.class.php

示例8: error

 /**
  * Create JSON error response.
  *
  * @param $message
  * @param int|null $code
  * @param array $data
  * @return bool|int
  */
 function error($message = null, $code = 501, $data = [])
 {
     if (is_int($code)) {
         http_response_code($code);
     }
     return json(array_merge(['error' => true, 'ok' => false], $message ? ['message' => $message] : [], $data));
 }
开发者ID:sphido,项目名称:json,代码行数:15,代码来源:json.php

示例9: testResid

 public function testResid()
 {
     $redis = Cache::redis();
     $redis->set('up', json(['info' => 1111, 'name' => 'xiaohb']));
     //        $this->redis->flushAll();
     //        $this->redis->set('up',json(['info'=>1111,'name'=>'xiaohb']));
     return $redis->get('up');
 }
开发者ID:v3u3i87,项目名称:upadd,代码行数:8,代码来源:HomeAction.php

示例10: deleteShortcut

 public function deleteShortcut(Request $request)
 {
     if (Shortcuts::where('user_id', $request->input('_user')['id'])->where('name', $request->input('name'))->delete()) {
         return json(['status' => 'ok']);
     } else {
         return json(error(2002));
     }
 }
开发者ID:koyeo,项目名称:bichon,代码行数:8,代码来源:Config.php

示例11: request

 /**
  * 获取请求记录
  * @param 内容 $cont
  * @param 文件名称以及格式 $file
  */
 public static function request($cont, $fileName = 'request.logs')
 {
     $cont['url'] = self::getHttpUrl();
     $cont['time'] = date('Y-m-d H:i:s');
     $content = json($cont) . ",\r";
     $file = self::isBak($fileName);
     file_put_contents($file, $content, FILE_APPEND | LOCK_EX);
 }
开发者ID:v3u3i87,项目名称:upadd,代码行数:13,代码来源:Log.php

示例12: ajax_change_type

 public function ajax_change_type()
 {
     $to = intval($this->_get('to'));
     $u['id'] = $this->login_user['id'];
     $u['apply_type_id'] = $to;
     M("UserInfo")->save($u);
     json(NULL, 'refresh');
 }
开发者ID:Germey,项目名称:yinxingapply,代码行数:8,代码来源:UserinfoAction.class.php

示例13: delete

 public function delete($id)
 {
     $id = intval($id);
     // 关联文章
     M('Tag')->where(array('id' => $id))->delete();
     session('success', '删除标签成功');
     json(NULL, 'refresh');
 }
开发者ID:Germey,项目名称:SimpleCMS,代码行数:8,代码来源:TagController.class.php

示例14: extend

 function extend($path = '')
 {
     if (empty($path)) {
         json('1002', '模板路径错误!');
     } else {
         $page = Page::init();
         $page->extend($path);
     }
 }
开发者ID:imjcw,项目名称:framework,代码行数:9,代码来源:Page.php

示例15: webfiles_response

function webfiles_response($data)
{
    header('HTTP/1.1 200 OK');
    header('Content-Type: application/json');
    $data = json($data);
    header('Content-Length: ' . strlen($data));
    echo $data;
    exit;
}
开发者ID:vojtajina,项目名称:sitellite,代码行数:9,代码来源:index.php


注:本文中的json函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。