本文整理汇总了PHP中json_return函数的典型用法代码示例。如果您正苦于以下问题:PHP json_return函数的具体用法?PHP json_return怎么用?PHP json_return使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了json_return函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: appControllerLoad
public function appControllerLoad()
{
$TestModel = new TestModel();
$list = $TestModel->getList();
json_return($list);
test();
}
示例2: upload1
public function upload1()
{
if (IS_POST) {
$upload = new \Think\Upload();
// 实例化上传类
$upload->maxSize = 3145728;
// 设置附件上传大小
$upload->exts = array('jpg', 'gif', 'png', 'jpeg');
// 设置附件上传类型
$upload->rootPath = './Uploads/';
// 设置附件上传根目录
$upload->savePath = 'mytest/';
// 设置附件上传(子)目录
// 上传文件
$info = $upload->upload();
if (!$info) {
// 上传错误提示错误信息
// $this->ajaxReturn($upload->getError(),"AJAX_UPLOAD");
$this->ajaxReturn(sp_ajax_return(array(), $upload->getError(), 0), "AJAX_UPLOAD");
} else {
// 上传成功
// $this->ajaxReturn('ssss',"AJAX_UPLOAD");
// $this->ajaxReturn(sp_ajax_return(array("file"=>array(1,2,3)),"上传成功!",1),"AJAX_UPLOAD");
echo json_return($info, 'ooo', 1);
// echo 'okkkk';
}
} else {
$this->display();
}
}
示例3: see_tmp_qrcode
public function see_tmp_qrcode()
{
if (empty($_GET['qrcode_id'])) {
json_return(1, '无法得到二维码图片!');
}
$qrcode_return = M('Recognition')->get_tmp_qrcode($_GET['qrcode_id']);
json_return(0, $qrcode_return);
}
示例4: message_weidu_count
function message_weidu_count()
{
$friendrequest = D('friendrequest');
$count = $this->Message->where("receiver_en_id = '%s' and readed = 0 and deleted = 0", array($this->myenid))->count();
$num = $friendrequest->where("receiver_en_id = '%s'", array($this->myenid))->count();
$sum = $count + $num;
json_return(200, 'success', $sum);
}
示例5: area
function area()
{
$city_code = I('get.city_code');
is_numeric($city_code) ? $city_code : json_return(400, '城市code不符合要求');
$citys = D('citys');
$where['parentId'] = $city_code;
$data = $citys->field('name,code')->where($where)->select();
empty($data) ? json_return(400, '为空') : json_return(200, '成功', $data);
}
示例6: awayErrorHandle
/**
* AwayAPI 运行文件,执行框架初始化,运行等
*
* @copyright Copyright (c) 2013-2014 Awaysoft.Com (http://www.awaysoft.com)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @version Version 0.1.0
* @link http://AwayAPI.awaysoft.com
* @since File available since Release 0.1.0
* @author Tom <tom@awaysoft.com>
*/
function awayErrorHandle($errno, $errstr, $errfile, $errline, $errarg)
{
/* 调试模式启用 */
if (RUN_MODE === 1) {
$log = '[' . $errno . ']' . $errstr . ':' . $errfile . ':' . $errline;
Log::write($log);
if ($errno === E_ERROR || $errno === E_USER_ERROR) {
$debugBacktrace = debug_backtrace();
array_shift($debugBacktrace);
Log::save();
json_return($debugBacktrace, 1, '发生严重错误');
}
}
/* 继续交由error_reporting()处理 */
return false;
}
示例7: get_usercoupon_list
function get_usercoupon_list($wap_user)
{
$page = $_POST['page'] ? $_POST['page'] : '1';
$type = $_REQUEST['type'];
$time = time();
//$type = 'used';
$type_arr = array('all', 'used', 'unused');
if (!in_array($type, $type_arr)) {
$type = 'all';
}
$where = array();
switch ($type) {
case 'unused':
$where['is_use'] = 0;
$where['end_time'] = array('>', $time);
break;
case 'used':
$where['is_use'] = 1;
break;
case 'expired':
$where['is_use'] = 0;
$where['end_time'] = array('<', $time);
break;
default:
break;
}
$where['delete_flg'] = '0';
$where['uid'] = $wap_user['uid'];
if ($page == 1) {
$json_return['count'] = D('User_coupon')->where($where)->count('id');
}
//$order_by = "";
$limit = 10;
$offset = ($page - 1) * $limit;
$order_by = '';
$coupon_list = M('User_coupon')->getList($where, $order_by, $limit, $offset);
$store_id_list = array();
foreach ($coupon_list as $coupon) {
$store_id_list[$coupon['store_id']] = $coupon['store_id'];
}
$store_list = M('Store')->getStoreName($store_id_list);
$json_return['list'] = $coupon_list;
if (count($json_return['list']) < 10) {
$json_return['noNextPage'] = true;
}
json_return(0, $json_return);
}
示例8: _collect
private function _collect($uid)
{
$type = $_GET['type'];
$dataid = $_GET['dataid'];
$time = time();
if (!in_array($type, array(1, 2)) || !isset($dataid)) {
echo json_return(501, '非法操作');
}
$data['user_id'] = $where['user_id'] = $uid;
$data['type'] = $where['type'] = $type;
$data['dataid'] = $where['dataid'] = $dataid;
$data['add_time'] = $time;
$collect = D('User_collect')->where($where)->find();
if ($collect) {
echo json_return(502, '已收藏');
}
if (D('User_collect')->data($data)->add()) {
json_return(0, '保存成功');
} else {
json_return(503, '保存失败');
}
}
示例9: halt
/**
* halt
+-----------------------------------------
* @access public
* @param ErrorException $e
* @return void
*/
static function halt($e)
{
self::append($e);
if (IS_AJAX) {
$code = $e->getCode();
json_return(null, $code ? $code : 9999, $e->getMessage());
}
if (DEBUG) {
$traceInfo = '';
$trace = $e->getTrace();
foreach ($trace as $t) {
$traceInfo .= $t['file'] . ' (' . $t['line'] . ') ';
$traceInfo .= $t['class'] . $t['type'] . $t['function'] . '(';
foreach ($t['args'] as $k => $arg) {
if ($k != 0) {
$traceInfo .= ',';
}
switch (gettype($arg)) {
case 'object':
case 'array':
$traceInfo .= '<b title="' . addslashes(var_export($arg)) . '">' . ucfirst(gettype($arg)) . '</b>';
break;
default:
$traceInfo .= $arg;
}
}
$traceInfo .= ")\n";
}
$message = $e->getMessage() . ' File:' . $e->getFile() . ' Line:' . $e->getLine();
debug::log($message, 'Error');
include COMMON_PATH . '500.php';
exit;
} else {
//否则定向到错误页面
redirect(WEB_PATH . '500.html');
}
exit;
}
示例10: D
$database_user = D('User');
if ($database_user->field('`uid`')->where(array('phone' => $_POST['phone']))->find()) {
json_return(1014, '手机号码已存在');
}
$data = array();
$data['phone'] = trim($_POST['phone']);
$data['nickname'] = '';
$data['password'] = md5(trim($_POST['pwd']));
$data['check_phone'] = 1;
$data['login_count'] = 1;
if (!empty($_SESSION['openid'])) {
$data['openid'] = $_SESSION['openid'];
}
$add_result = M('User')->add_user($data);
if ($add_result['err_code'] == 0) {
$_SESSION['wap_user'] = $add_result['err_msg'];
mergeSessionUserInfo(session_id(), $add_result['err_msg']['uid']);
json_return(0, '注册成功');
} else {
json_return(1, $add_result['err_msg']);
}
}
} else {
//回调地址
$redirect_uri = $_GET['referer'] ? $_GET['referer'] : ($_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : ($_COOKIE['wap_store_id'] ? './home.php?id=' . $_COOKIE['wap_store_id'] : $config['site_url']));
if (!empty($_SESSION['wap_user'])) {
redirect($redirect_uri);
}
include display('login');
echo ob_get_clean();
}
示例11: A
if (empty($ret)) {
$errmsg = A($class)->act_getErrorMsg();
if (!empty($errmsg)) {
json_return($errmsg);
}
}
//对返回数据进行封装
$package = !empty($data[0]['extend_package']) ? $data[0]['extend_package'] : 'Package:commonPackage';
list($pclass, $pfun) = explode(':', $package);
$pmethod = ucfirst($pclass . "Act");
$pfun = 'act_' . $pfun;
if (!class_exists($pmethod)) {
json_return(10176);
}
if (!method_exists($pmethod, $pfun)) {
json_return(10176);
}
$ret = A($pclass)->{$pfun}($ret);
$callback = isset($_GET['callback']) ? $_GET['callback'] : "";
$jsonp = isset($_GET['jsonp']) ? $_GET['jsonp'] : "";
$data = array("errCode" => 200, "errMsg" => get_promptmsg(10172), "status" => true, "data" => $ret);
if (!empty($callback)) {
if (!empty($jsonp)) {
echo "try{ " . $callback . "(" . json_encode($data) . "); }catch(){alert(e);}";
} else {
echo $callback . "(" . json_encode($data) . ");";
}
} else {
echo json_encode($data);
}
exit;
示例12: dirname
<?php
/**
* Created by PhpStorm.
* User: pigcms_21
* Date: 2015/5/11
* Time: 10:29
*/
require_once dirname(__FILE__) . '/global.php';
if (IS_POST && empty($_SESSION['wap_user'])) {
json_return(10000, '操作失败,您还未登录');
} else {
if (empty($_SESSION['wap_user'])) {
redirect('./login.php');
}
}
if (!option('config.open_store_drp')) {
//未开启排他分销
if (!empty($_COOKIE['wap_store_id'])) {
redirect('./ucenter.php?id=' . $_COOKIE['wap_store_id']);
} else {
pigcms_tips('抱歉,您没有权限访问', 'none');
}
}
$flag = true;
$tmp_store = D('Store')->field('uid,open_drp_limit,drp_limit_buy,drp_limit_share,drp_limit_condition')->where(array('store_id' => $_GET['id']))->find();
if (!empty($tmp_store['open_drp_limit']) && $_SESSION['wap_user']['uid'] != $tmp_store['uid']) {
//分销限制
if (!empty($tmp_store['drp_limit_buy'])) {
//消费满多少
$array = array();
示例13: _reward_edit
private function _reward_edit()
{
$id = $_REQUEST['id'] + 0;
if (empty($id)) {
json_return(1001, '缺少最基本的参数ID');
exit;
}
$reward_model = M('Reward');
$where = array();
$where['uid'] = $_SESSION['store']['uid'];
$where['store_id'] = $_SESSION['store']['store_id'];
$where['id'] = $id;
$reward = $reward_model->getReward($where);
if (empty($reward)) {
json_return(1001, '未找到相应的优惠活动');
exit;
}
if (IS_POST && isset($_POST['is_submit'])) {
$name = $_POST['name'];
$start_time = $_POST['start_time'];
$end_time = $_POST['end_time'];
$is_all = $_POST['is_all'];
$reward_str = $_POST['reward_str'];
$product_id = $_POST['product_id'];
if (empty($name)) {
json_return(1001, '活动名称没有填写,请填写');
}
if (empty($start_time)) {
json_return(1001, '请选择活动开始时间');
}
if (empty($end_time)) {
json_return(1001, '请选择活动结束时间');
}
if (empty($reward_str)) {
json_return(1001, '请至少设置一个优惠门槛');
}
// 查找参与活动的产品列表
$product_exist = '';
$time = time();
$where = array();
$where['store_id'] = $_SESSION['store']['store_id'];
$where['uid'] = $_SESSION['store']['uid'];
$where['status'] = 1;
$where['start_time'] = array('<=', $time);
$where['end_time'] = array('>=', $time);
$where['is_all'] = 1;
if (!empty($id)) {
$where['id'] = array("!=", $id);
}
$reward = M('Reward')->getReward($where);
if (!empty($reward)) {
$product_exist = 'ALL';
} else {
$product_exist = M('Reward_product')->getProductIDList($id);
}
if ($product_exist == 'ALL') {
json_return(1001, '您有其他正在进行的满就减活动,无法设置商品参与');
} else {
if ($is_all == 'all' && !empty($product_exist)) {
json_return(1001, '您有其他正在进行的满就减活动,无法设置商品参与');
} else {
$product_id_arr = explode(',', $product_id);
if (array_intersect($product_id_arr, $product_exist)) {
json_return(1001, '您有其他正在进行的满就减活动,无法设置商品参与');
}
}
}
// 优惠门槛格式:12,cash:12,postage:1,score:12,coupon:11,present:1
$reward_arr = explode('|', $reward_str);
$reward_condition_arr = array();
foreach ($reward_arr as $tmp) {
$reward_each_arr = explode(',', $tmp);
if (count($reward_each_arr) == 1 && $reward_each_arr[0] + 0 < 0) {
json_return(1001, '您设置一个优惠门槛有误,请重新设置');
}
$data = array();
foreach ($reward_each_arr as $key => $tmp) {
if ($key == 0) {
continue;
}
list($condition, $value) = explode(':', $tmp);
$data[$condition] = $value;
if ($condition == 'cash') {
$value += 0;
$value = max(0, $value);
if (empty($value)) {
json_return(1001, '请正确填写减的金额');
}
} else {
if ($condition == 'score') {
$value += 0;
$value = ceil(max(0, $value));
if (empty($value)) {
json_return(1001, '请正确填写减的金额');
}
} else {
if ($condition == 'coupon') {
$value += 0;
$value = ceil(max(0, $value));
if (empty($value)) {
//.........这里部分代码省略.........
示例14: addSerialNumber
public function addSerialNumber()
{
if (IS_AJAX) {
$goods_name = trim($_POST['goods_name']);
$goods_id = M('Goods')->where(array('goods_name' => $goods_name))->getField('goods_id');
json_return(200, $goods_id, $goods_id);
} elseif (IS_POST) {
$data['goods_id'] = intval($_POST['goods_id']);
$data['serial_number'] = trim($_POST['serial_number']);
$res = M('Serial')->add($data);
if ($res) {
$this->success('添加序列号成功');
} else {
$this->error('添加序列号失败');
}
} elseif (IS_GET) {
$serial_number = trim($_GET['serial_number']);
$this->info = M('Serial')->where(array('serial_number' => $serial_number))->find();
$this->display();
}
}
示例15: base64_decode
//trim($cover[0]);
// save picture
@file_put_contents(PT_PATH . 'picture/' . $product['id'] . '.jpg', base64_decode($cover[1]));
}
}
// preg product's star
if (preg_match('/5つ星のうち ([0-9.]+)/i', $html, $star)) {
$product['star'] = $star[1];
}
$db->beginTrans();
$product = filter::apply('refresh', $product, $html);
// Save
$id = $product['id'];
unset($product['id']);
list($sql, $value) = array_values(update_array($product));
$value[':id'] = $id;
$rs = $db->prepare("UPDATE `a_good` SET {$sql} WHERE `id`=:id")->execute($value);
if ($rs === false) {
$db->rollback();
json_return(null, 1, 'Load page\'s data fail, please retry.');
}
// Commit
if (!$db->commit()) {
$db->rollback();
json_return(null, 9, 'Load page\'s data fail, please retry.');
}
$product['id'] = $id;
template::assign('v', $product);
$html = template::fetch('_tr');
json_return($html);