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


PHP output_json函数代码示例

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


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

示例1: repjson

 /**
  * @param array $data
  * @param int $code
  */
 protected function repjson($data = [], $code = 200)
 {
     if ($code !== 200) {
         $this->response->withStatus($code, Http\Http::getStatus($code));
     }
     $this->response->withHeader('Content-Type', 'application/json; charset=' . getini('site/charset'));
     $data = $data ? output_json($data) : '';
     $this->response->write($data);
 }
开发者ID:locphp,项目名称:rsf,代码行数:13,代码来源:Controller.php

示例2: set

 public function set($key, $value, $ttl = 0)
 {
     $ret = false;
     if ($this->enable) {
         $data = [$value];
         $ret = $this->cacher->set($this->_key($key), output_json($data), $ttl);
     }
     return $ret;
 }
开发者ID:locphp,项目名称:rsf,代码行数:9,代码来源:Cacher.php

示例3: GetLocalMessage

 /**
  * 获取当前坐标附近的消息
  */
 function GetLocalMessage()
 {
     $latitude = isset($_REQUEST['latitude']) ? (double) $_REQUEST['latitude'] : 0;
     $longitude = isset($_REQUEST['longitude']) ? (double) $_REQUEST['longitude'] : 0;
     $imei = isset($_REQUEST['imei']) ? $_REQUEST['imei'] : 0;
     $messList = mdl_message_item::getInstance()->GetAppointCoordinateMessage($latitude, $longitude);
     $result = array('state' => "1", 'message' => $messList);
     output_json($result);
 }
开发者ID:kiah2008,项目名称:coordinate-talk.swtphp,代码行数:12,代码来源:message.php

示例4: json_respond

/**

		We will respond to all requests with a JSON response :)

	**/
function json_respond($status, $msg)
{
    if ($status != "OK") {
        // Log Failures.
        $logmsg = "RXALARM - POSTFAIL - " . $status . " - " . $msg;
        error_log($logmsg, 0);
    }
    $output = array('status' => $status, 'msg' => $msg);
    output_json($output);
}
开发者ID:mp459,项目名称:rxalarm,代码行数:15,代码来源:rackspace.php

示例5: student

 public function student()
 {
     $userdata = $this->session->userdata;
     if ($userdata['exam_ticket_out'] > 0 && $userdata['txt_student_tichu'] == 1) {
         output_json(CODE_SUCCESS, 'success', 'fail');
         die;
     } else {
         output_json(CODE_SUCCESS, 'success', 'success');
         die;
     }
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:11,代码来源:log.php

示例6: GsmToGps

 /**
  * 通过GSM基站信息解析出gps坐标
  */
 function GsmToGps()
 {
     $cellId = isset($_REQUEST['cid']) ? (int) $_REQUEST['cid'] : 0;
     $locationAreaCode = isset($_REQUEST['lac']) ? (int) $_REQUEST['lac'] : 0;
     $mobileCountryCode = isset($_REQUEST['mcc']) ? (int) $_REQUEST['mcc'] : 0;
     $mobileNetworkCode = isset($_REQUEST['mnc']) ? (int) $_REQUEST['mnc'] : 0;
     $imei = isset($_REQUEST['imei']) ? $_REQUEST['imei'] : 0;
     $locale = tls_gpsparse::GsmToGps($cellId, $locationAreaCode, $mobileCountryCode, $mobileNetworkCode);
     //解析地址
     $AddressZH = tls_gpsparse::GetAddress($locale['latitude'], $locale['longitude'], 'zhcn');
     //记日志
     mdl_log_gsm::getInstance()->ParseGsmToGpsLog($imei, $cellId, $locationAreaCode, $mobileCountryCode, $mobileNetworkCode, $locale['latitude'], $locale['longitude'], $AddressZH);
     //返回结果
     $result = array('state' => "1", 'message' => $locale);
     output_json($result);
 }
开发者ID:kiah2008,项目名称:coordinate-talk.swtphp,代码行数:19,代码来源:gsm.php

示例7: datacache

/**
 * 有模型的缓存  model/data/*.php
 * @param $cachekey
 * @param bool $reset
 * @return bool|mixed|void
 */
function datacache($cachekey, $reset = false)
{
    if (!$cachekey) {
        return false;
    }
    if (!$reset) {
        $data = cache('get', $cachekey);
        if (is_null($data)) {
            $dataclass = '\\Model\\Data\\' . ucfirst($cachekey);
            $data = $dataclass::getInstance()->getdata();
            cache('set', $cachekey, output_json($data));
        } else {
            $data = json_decode($data, true);
        }
        return $data;
    } else {
        //重置缓存
        $dataclass = '\\Model\\Data\\' . ucfirst($cachekey);
        $data = $dataclass::getInstance()->getdata();
        return cache('set', $cachekey, output_json($data));
    }
}
开发者ID:locphp,项目名称:rsf,代码行数:28,代码来源:function.php

示例8: message

 function message($message, $uri = null, $msg_type = 'notice', $redirect_time = 5)
 {
     $CI =& get_instance();
     //如果是ajax请求,则返回json数据
     if ($CI->input->is_ajax_request()) {
         if ($msg_type == 'success') {
             output_json(CODE_SUCCESS, $message, array(), $uri);
         } else {
             output_json(CODE_ERROR, $message, array(), $uri);
         }
     }
     $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/';
     if ($uri || $referer) {
         if ($uri !== false) {
             if (empty($uri)) {
                 $uri = 'javascript:history.go(-1);';
             } else {
                 if (substr($uri, 0, 10) != 'javascript' && substr($uri, 0, 4) != 'http') {
                     $uri = site_url($uri);
                 }
                 if (substr($uri, 0, 10) == 'javascript') {
                     $uri = $referer;
                 }
             }
         }
     } else {
         $uri = 'javascript:history.go(-1);';
     }
     $data['msg_type'] = $msg_type;
     $data['message'] = $message;
     $data['url_forward'] = $uri;
     $data['redirect_time'] = $redirect_time * 1000;
     $content = $CI->load->view('common/message', $data, TRUE);
     ob_end_clean();
     echo $content;
     exit;
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:37,代码来源:site_helper.php

示例9: st_multi

                }
            } else {
                //echo "mind 2";
                $postgis_diff = "\r\n            UPDATE\r\n              temp_reach_hull\r\n            SET\r\n              diff = (\r\n                SELECT\r\n                  st_multi(\r\n                    ST_SymDifference(t1.the_geom, t2.the_geom)\r\n                  ) AS diff\r\n                FROM\r\n                  (\r\n                    SELECT\r\n                      the_geom\r\n                    FROM\r\n                      temp_reach_hull\r\n                    WHERE\r\n                      id=" . $ids[$intervall - $i - 1] . "\r\n                  ) AS t1,\r\n                  (\r\n                    SELECT\r\n                      the_geom\r\n                    FROM\r\n                      temp_reach_hull\r\n                    WHERE\r\n                      id=" . $ids[$intervall - $i] . "\r\n                  ) AS t2\r\n                )\r\n              WHERE\r\n                id=" . $ids[$intervall - $i - 1] . "\r\n              RETURNING\r\n                ST_AsGeoJSON(diff)\r\n            ";
                //echo $postgis_diff.'<br>';
                $result_geojson = pg_query($db_conn, $postgis_diff);
                $row_geojson = pg_fetch_array($result_geojson);
                $geojson = $row_geojson[0];
                //echo "geojson Nr. ".$i." :".print_r(json_decode($geojson)->coordinates)."<br>";
                if ($featCollVal == "true") {
                    array_push($geo, buildFeature(json_decode($geojson), $minutesCount));
                }
                if ($featCollVal == "false") {
                    array_push($geo, json_decode($geojson)->coordinates);
                }
            }
        }
    }
    //X. delete temp hulls from PostGIS db
    foreach ($ids as $id) {
        clearEntry($id, $schema, "temp_reach_hull");
    }
    //baue FeatureCollection oder MultiPolygon mit den HullPolygonen im Array $geo und gebe am Ende das Ergebnis als GeoJSON aus
    if ($featCollVal == "true") {
        $json_output = buildFeatureCollection($geo);
    }
    if ($featCollVal == "false") {
        $json_output = buildMultiPolygon($geo);
    }
    output_json(json_encode($json_output));
}
开发者ID:pkorduan,项目名称:reach,代码行数:31,代码来源:reach.php

示例10: reset_password

 /**
  * @description 重置密码
  * @author
  * @final
  * @param int $uid 学生id
  * @param string $new_password 新密码
  * @param string $confirm_password 重复密码
  */
 public function reset_password()
 {
     if (!$this->check_power('student_manage')) {
         return;
     }
     $new_password = $this->input->post('new_password');
     $new_confirm_password = $this->input->post('confirm_password');
     $uid = intval($this->input->post('uid'));
     if (is_string($passwd_msg = is_password($new_password))) {
         output_json(CODE_ERROR, $passwd_msg);
     }
     if (!strlen(trim($new_confirm_password))) {
         output_json(CODE_ERROR, '确认密码不能为空.');
     }
     if ($new_confirm_password != $new_password) {
         output_json(CODE_ERROR, '两次密码输入不一致.');
     }
     //检查是否存在该学生
     $passwd = StudentModel::get_student($uid, 'password');
     if (!count($passwd)) {
         output_json(CODE_ERROR, '不存在该学生.');
     }
     //修改学生密码
     $flag = StudentModel::reset_password($uid, my_md5($new_password));
     if (!$flag) {
         output_json(CODE_ERROR, '密码修改失败,请重试');
     }
     output_json(CODE_SUCCESS, '密码修改成功.');
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:37,代码来源:student.php

示例11: define

// // // // foreach($val as $k=>$v){
// // // // echo "$k:$v;";
// // // // }
// // // // echo "<br />";
// // // // }
//// TES POTONGAN KODE IVAN R. LANIN
define(LF, "\r\n");
// Tampilkan hasil
if ($data) {
    $rows = count($data);
    switch ($_GET['f']) {
        case 'xml':
            $ret .= output_xml($data);
            break;
        case 'json':
            $ret .= output_json($data);
            break;
        case 'csv':
            foreach ($data[0] as $column => $value) {
                $head .= ($head ? ',' : '') . $column;
            }
            $ret .= $head . LF;
            foreach ($data as $rows) {
                $row = '';
                foreach ($rows as $column => $value) {
                    $row .= ($row ? ',' : '') . $value;
                }
                $ret .= $row . LF;
            }
            break;
        default:
开发者ID:cakpep,项目名称:Gudang-Data-Indonesia,代码行数:31,代码来源:browse.php

示例12: elseif

} elseif ($act == "add") {
    $id = isset($_REQUEST["id"]) ? intval($_REQUEST["id"]) : 0;
    if ($id) {
        $row = $db->get_row("select * from data where id = " . $id, ARRAY_A);
        $row["content"] = html_entity_decode($row["content"]);
    } else {
        $row = array("id" => 0, "name" => "", "sort" => 0, "dataclass_id" => 0, "content" => "", "type" => intval($_REQUEST['type']));
    }
    $smarty->assign('row', $row);
    $smarty->display('admin/admin_data_add.html');
} elseif ($act == "addsubmit") {
    $list = array("name" => str_filter($_REQUEST["name"]), "content" => str_filter($_REQUEST["content"]), "sort" => intval($_REQUEST["sort"]), "dataclass_id" => intval($_REQUEST["dataclass_id"]), "type" => intval($_REQUEST["type"]));
    $id = isset($_REQUEST["id"]) ? intval($_REQUEST["id"]) : 0;
    if ($id) {
        $sql = SqlText::update("data", $list, "id=" . $id);
        $db->query($sql);
        output_json(0, "更新成功");
    } else {
        $list["add_time"] = time();
        $list["hits"] = 0;
        $sql = SqlText::insert("data", $list);
        $db->query($sql);
        output_json(0, "添加成功");
    }
} elseif ($act == "del") {
    $sql = "delete from data where id = " . intval($_REQUEST["id"]);
    $db->query($sql);
    output_json(0, "删除成功");
} else {
    exit("错误请求");
}
开发者ID:dalinhuang,项目名称:ozgweb,代码行数:31,代码来源:admin_data.php

示例13: get_exam_areas_bak

 /**
  * 获取某期考试 所考到的所有考场 按照地域分类,从高->低
  * 关联表:rd_region rd_exam_place rd_school
  *
  * @return  void
  */
 private function get_exam_areas_bak()
 {
     $exam_pid = intval($this->input->get('exam_pid'));
     $place_id = $this->input->get('place_id');
     if (!$exam_pid || $place_id == '') {
         output_json(CODE_SUCCESS, '', array());
     }
     if (!$place_id) {
         $result = $this->db->query("select s.* from {pre}school s, {pre}exam_place p where p.exam_pid={$exam_pid} and p.school_id=s.school_id group by school_id")->result_array();
     } else {
         $result = $this->db->query("select s.* from {pre}school s, {pre}exam_place p where p.exam_pid={$exam_pid} and p.place_id={$place_id} and p.school_id=s.school_id group by school_id")->result_array();
     }
     //按照地域级别深度 进行归档
     /*
      * 依次是 国家->省->地市->区县
      */
     $region_ids = array();
     foreach ($result as $item) {
         $region_ids[] = $item['province'];
         $region_ids[] = $item['city'];
         $region_ids[] = $item['area'];
     }
     $region_ids = array_unique($region_ids);
     //获取地域名称
     $region_ids = implode(', ', $region_ids);
     $region_result = $this->db->query("select region_id, region_name, region_type, parent_id from {pre}region where region_id in({$region_ids})")->result_array();
     $regions = array();
     $addresses = array();
     $parent_regions = array();
     foreach ($region_result as $val) {
         $regions[$val['region_id']] = array('name' => $val['region_name'], 'pid' => $val['parent_id']);
         $addresses[] = array($val['region_id'], $val['region_name'], $val['parent_id']);
         $parent_regions[$val['parent_id']][] = $val['region_id'];
     }
     $data = array('region' => array(array('region_type' => '0', 'id' => 'select_country', 'depth' => '0', 'name' => 'comparison_level_region', 'onchange' => "region.changed(this, 1, 'select_province{depth}');region.changed(document.getElementById('select_province{depth}'), 1, 'select_city{depth}');region.changed(document.getElementById('select_city{depth}'), 1, 'select_area{depth}');region.changed(document.getElementById('select_area{depth}'), 1, 'select_school{depth}');", 'data' => array(array('name' => '--请选择国家--', 'region_id' => '0'), array('name' => '中国', 'region_id' => '1')))));
     //当前对比等级
     $comparison_level = urldecode($this->input->get('comparison_level'));
     $comparison_level = (array) json_decode($comparison_level);
     $tmp_c_l = array();
     foreach ($comparison_level as $val) {
         $tmp_c_l[] = (array) $val;
     }
     $comparison_level = is_array($tmp_c_l) ? $tmp_c_l : array();
     $cl_region = isset($comparison_level[0]['region']) ? $comparison_level[0]['region'] : '';
     $cl_school = isset($comparison_level[0]['school']) ? $comparison_level[0]['school'] : 0;
     $cl_country = isset($cl_region[0]) ? $cl_region[0] : 0;
     $cl_province = isset($cl_region[1]) ? $cl_region[1] : 0;
     $cl_city = isset($cl_region[2]) ? $cl_region[2] : 0;
     $cl_area = isset($cl_region[3]) ? $cl_region[3] : 0;
     $provinces = array(array('name' => '--请选择省--', 'region_id' => '0', 'pid' => '0'));
     $cities = array(array('name' => '--请选择市--', 'region_id' => '0', 'pid' => '0'));
     $areas = array(array('name' => '--请选择区县--', 'region_id' => '0', 'pid' => '0'));
     $schools = array(array('name' => '--请选择学校--', 'school_id' => '0', 'pid' => '0'));
     foreach ($result as $item) {
         $cl_country && ($provinces[] = array('name' => isset($regions[$item['province']]) ? $regions[$item['province']]['name'] : '--', 'region_id' => $item['province'], 'pid' => isset($regions[$item['province']]) ? $regions[$item['province']]['pid'] : '0'));
         $cities[] = array('name' => isset($regions[$item['city']]) ? $regions[$item['city']]['name'] : '--', 'region_id' => $item['city'], 'pid' => isset($regions[$item['city']]) ? $regions[$item['city']]['pid'] : '0');
         $areas[] = array('name' => isset($regions[$item['area']]) ? $regions[$item['area']]['name'] : '--', 'region_id' => $item['area'], 'pid' => isset($regions[$item['area']]) ? $regions[$item['area']]['pid'] : '0');
         $schools[] = array('name' => $item['school_name'], 'school_id' => $item['school_id'], 'pid' => $item['area']);
         //id需要加1000 为了区分区域
         $addresses[] = array(100000 + $item['school_id'], $item['school_name'], $item['area']);
     }
     //地域
     $data['region'][] = array('region_type' => '1', 'id' => 'select_province', 'depth' => '1', 'name' => 'comparison_level_region', 'onchange' => "region.changed(this, 2, 'select_city{depth}');region.changed(document.getElementById('select_city{depth}'), 2, 'select_area{depth}');region.changed(document.getElementById('select_area{depth}'), 2, 'select_school{depth}');", 'data' => $provinces);
     $data['region'][] = array('region_type' => '2', 'id' => 'select_city', 'depth' => '2', 'name' => 'comparison_level_region', 'onchange' => "region.changed(this, 3, 'select_area{depth}');region.changed(document.getElementById('select_area{depth}'), 3, 'select_school{depth}');", 'data' => $cities);
     $data['region'][] = array('region_type' => '3', 'id' => 'select_area', 'depth' => '3', 'name' => 'comparison_level_region', 'onchange' => "region.changed(this, 4, 'select_school{depth}');", 'data' => $areas);
     //学校
     $data['school'] = array('id' => 'select_school', 'depth' => '4', 'name' => 'comparison_level_school', 'data' => $schools);
     //所有地区缓存
     $data['address'] = $addresses;
     output_json(CODE_SUCCESS, '', $data);
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:77,代码来源:evaluate_rule.php

示例14: get

 /**
  * 
  * 获取用户信息, 昵称 / 头像 / ...
  */
 function get()
 {
     $uid = isset($_REQUEST['uid']) ? (int) $_REQUEST['uid'] : 0;
     $d = !empty($uid) ? mdl_account_basic::getInstance()->get($uid) : array();
     output_json($d);
 }
开发者ID:kiah2008,项目名称:coordinate-talk.swtphp,代码行数:10,代码来源:account.php

示例15: header

                            $args[$param->getName()] = $param->getDefaultValue();
                        } else {
                            header('HTTP/1.0 400 Bad Request');
                            echo "400 Expected Argument Not Specified ({$param->getName()})";
                            exit;
                            continue;
                        }
                    } else {
                        $args[$param->getName()] = $_REQUEST[$param->getName()];
                        unset($_REQUEST[$param->getName()]);
                    }
                }
                if (!empty($_REQUEST)) {
                    header('HTTP/1.0 400 Bad Request');
                    $k = array_keys($_REQUEST);
                    echo "400 Invalid Argument ({$k[0]})";
                    exit;
                }
                // TODO try catch
                $out = $reflector->invokeArgs(api($api), $args);
                // TODO Type en fonction + ajouter XML + CSV
                header("Content-type: application/json");
                echo output_json($out);
            } else {
                header('HTTP/1.0 400 Bad Request');
                echo "400 Bad Request (dn={$dn})";
                exit;
            }
        }
    }
}
开发者ID:rbello,项目名称:ent,代码行数:31,代码来源:api.php


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