• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP json函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: locale

 function locale()
 {
     $locale = Cookie::get('locale');
     if (!$locale) {
         $locale = 'cn';
     }
     Cookie::set('locale', $locale == 'cn' ? 'tw' : 'cn');
     json($html, "refresh");
 }
开发者ID:Germey,项目名称:yinxingapply,代码行数:9,代码来源:CommonAction.class.php


示例17: ajax_image_dialog

 function ajax_image_dialog()
 {
     $id = $this->_param("id");
     if ($id) {
         $image = M("Images")->getById($id);
     }
     $this->assign("image", $image);
     $html = $this->fetch("Common:Public:image_dialog");
     json($html, "dialog");
 }
开发者ID:Germey,项目名称:yinxingpm,代码行数:10,代码来源:CommonAction.class.php


示例18: delete

 public function delete($id = NULL)
 {
     $id = intval($id);
     if (!$id) {
         return;
     }
     M("Config")->where('id=' . $id)->delete();
     session('success', '删除成功');
     json(NULL, 'refresh');
 }
开发者ID:Germey,项目名称:SimpleCMS,代码行数:10,代码来源:ConfigController.class.php


示例19: delete

 public function delete($id = 0)
 {
     $id = intval($id);
     if (!$id) {
         return;
     }
     M("Extend")->where('id=' . $id)->delete();
     session('error', '删除扩展方案成功');
     json(U('Extend/index'), 'redirect');
 }
开发者ID:Germey,项目名称:SimpleCMS,代码行数:10,代码来源:ExtendController.class.php


示例20: store

 /**
  * Create a new user.
  * 
  * @return Response
  */
 public function store()
 {
     $input = Input::only('email', 'password', 'first_name', 'last_name', 'county_id', 'g-recaptcha-response');
     $this->registrationForm->validate($input);
     $user = User::create(['email' => $input['email'], 'password' => $input['password'], 'first_name' => $input['first_name'], 'last_name' => $input['last_name'], 'role_id' => config('auth.default_role_id'), 'county_id' => 20]);
     $user->regenerateConfirmationToken();
     $this->mailer->sendConfirmationLink($user);
     flash(true);
     return json(true);
 }
开发者ID:adriancatalinsv,项目名称:fiip,代码行数:15,代码来源:RegistrationController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP jsonDecode函数代码示例发布时间:2022-05-15
下一篇:
PHP jsg_member_info函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap