本文整理汇总了PHP中responseJSON函数的典型用法代码示例。如果您正苦于以下问题:PHP responseJSON函数的具体用法?PHP responseJSON怎么用?PHP responseJSON使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了responseJSON函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
header('Content-type: text/json; charset=UTF-8');
require_once "../include/global.include.php";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$returnArr = array('code' => 200);
if (!check_session()) {
responseJSON('session expired', 440);
}
extract($_POST);
if (!isset($media_id)) {
responseJSON('invalid request');
}
try {
foreach ($media_id as $id) {
$result = $wechat->dropMedia($id);
if ($result['hasError']) {
$returnArr = array('code' => 400, 'err' => $result['err']);
break;
}
$query = 'UPDATE media_image SET deleted = 1 WHERE media_id = ?';
if (!$mysql->execute($query, array($id))) {
throw new Exception($mysql->error);
}
}
} catch (Exception $ex) {
# log the exception
log_error('media_image: drop', json_encode($media_id), $ex->getMessage());
$returnArr = array('code' => 500, 'err' => $ex->getMessage());
}
responseJSON($returnArr);
}
示例2: actionDelete
public function actionDelete()
{
$id = $_POST['id'];
$sql = "delete from convey_answers where id=" . $id;
iQuery($sql);
responseJSON(['success' => true]);
}
示例3: array
<?php
$json = array();
$json['message'] = $message;
$json['amazing_level'] = $json['message'] === null ? $productModel->product_mark : null;
$json['commentList'] = null;
if ($message === null) {
foreach ($results as $key => $result) {
$json['commentList'][$key]['id'] = $result['id'];
$json['commentList'][$key]['text'] = $result['text'];
$json['commentList'][$key]['create_time'] = $result['create_time'];
$json['commentList'][$key]['amazing_level'] = $result['amazing_level'];
}
}
$json = JSON($json);
responseJSON($json);
示例4: header
<?php
header('Content-type: application/json; charset=UTF-8');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
require_once "../include/global.include.php";
$returnArr = array('code' => 200);
if (!check_session()) {
$returnArr['code'] = 440;
responseJSON('session expired', 440);
}
if (!isset($_FILES) || !isset($_GET['type'])) {
die(json_encode(array('code' => 400, 'err' => 'Invalid request')));
}
$type = $_GET['type'];
$file = $_FILES['Filedata'];
$imageData = getimagesize($file['tmp_name']);
$extension = image_type_to_extension($imageData[2]);
$available_type = array('image', 'thumb', 'voice', 'video');
try {
if (!in_array($type, $available_type)) {
die(json_encode(array('code' => 400, 'err' => 'Invalid media type')));
}
// --------- save file in server -------------
// the orignal filename
$filename = $file['name'];
// copy the file according to media type
$targetPath = "/upload/{$type}/";
$targetFileName = time() . $extension;
$targetFile = dirname(__DIR__) . $targetPath . $targetFileName;
if (!move_uploaded_file($file['tmp_name'], $targetFile)) {
throw new Exception('file cannot be saved');