本文整理匯總了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);