第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

app數(shù)據(jù)封裝

<?php
class Makejson{
?? ?/*
?? ?*按json方式生成通信數(shù)據(jù)數(shù)據(jù)
?? ?@param integer $code 狀態(tài)嗎
?? ?@param string $message 提示信息
?? ?@param array $data 數(shù)據(jù)
?? ?return string
?? ?//常量JSON表示默認(rèn)數(shù)據(jù)類型
?? ?*/
?? ?const JSON='json' ;
? public static function resulut($code,$message='',$data=array(),$type=self::JSON){
?? ??? if(!is_numeric($code)) return '';
?? ?? ?
?? ??? $type=isset($_GET['datatype'])?$_GET['datatype']:self::JSON;
?? ??? $result=array(
?? ???? 'code'=>$code,
?? ??? ?'message'=>$message,
?? ??? ?'data'=>$data
?? ??? );
?? ?? ?
?? ??? if($type=='json'){
?? ??? ??????? self::json($code,$message,$data);
?? ??? ??????? exit;? ?
?? ??? ?}else if($type=='array'){
?? ??? ??? ?? var_dump($result);
?? ??? ??? ?? exit;
?? ??? ?}else if($type=='xml'){
?? ??? ??????? self::xml($code,$message='',$data);
?? ??? ??? ??? exit;
?? ??? ?}else {
?? ??? ????? //? 待添加功能
?? ??? ??? ??? exit;
?? ??? ?}
?? ? ?
?? ? ?
?? ?? }
?? ?
? public static function json($code,$message='',$data=array()){
?? ? ?
?? ?if(!is_numeric($code)) return '';
?? ? $arr=array(
?? ? 'id'=>$code,
?? ? 'message'=>$message,
?? ? 'data'=>$data
?? ?? );
?? ? echo? json_encode($arr);
? }
?
?? /*
?? ?*按xml方式生成通信數(shù)據(jù)數(shù)據(jù)
?? ?@param integer $code 狀態(tài)嗎
?? ?@param string $message 提示信息
?? ?@param array $data 數(shù)據(jù)
?? ?return string
?? ?
?? ?*/
?public static function xml($code,$message='',$data=array()){
?? ? if(!is_numeric($code)) return '';
?? ? $arr=array(
?? ? 'id'=>$code,
?? ? 'message'=>$message,
?? ? 'data'=>$data
?? ?? );
?? ? header("Content-Type:text/xml");
?? ? $xml="<?xml version='1.0' encoding='UTF-8' ?> ";
?? ? $xml.="<root>";
?? ? $xml.="<code>".$code."</code>";
?? ? $xml.="<message>".$message."</message>";
?? ? $xml.="<data>";
?? ? $xml.=self::Toxml($data);
?? ? $xml.="</data>";
?? ? $xml.="</root>";
?? ? echo $xml;
? }
? public static function Toxml($arr=array()){
?? ?? $xml=$attr="";
?? ?? foreach($arr as $key=>$val){
?? ?????? if(is_numeric($key)){
?? ??? ??? ?? $attr="id='{$key}'";
?? ??? ??? ?? $key="item";
?? ??? ??? ?? }
?? ???????? $xml.="<{$key} {$attr}>";
?? ??? ??? ?$xml.=is_array($val)?self::Toxml($val):$val;
?? ??? ??? ?$xml.="</{$key}>";
?? ??? }
?? ??? return $xml;
?? ? ?
?? }
}

正在回答

舉報(bào)

0/150
提交
取消
PHP開(kāi)發(fā)APP接口
  • 參與學(xué)習(xí)       79151    人
  • 解答問(wèn)題       608    個(gè)

APP通信接口技術(shù),不得不掌握的法寶,學(xué)完之后你會(huì)受益良多

進(jìn)入課程

app數(shù)據(jù)封裝

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)