thikphp 簡單的介面骨架

來源:互聯網
上載者:User

標籤:style   blog   io   ar   color   使用   sp   for   on   

//get id 擷取內容,調用xml方法public function get(){$id = $_GET[‘id‘];//接收id$User = M(‘user‘);//$val->where("id = $id")->select();$data=$User->where( "id = $id" )->find();$this->arrtoxml($data);//dump($val);//dump($id);}//封裝成xmlpublic function arrtoxml($data,$dom=0,$item=0){if (!$dom){$dom=new DOMDocument("1.0");}if(!$item){$item=$dom->createElement("cti");$dom->appendChild($item);}foreach ($data as $key=>$val){$itemx=$dom->createElement(is_string($key)?$key:"item");$item->appendChild($itemx);if (!is_array($val)){$text =$dom->createTextNode($val);$itemx->appendChild($text);}else{$this->arrtoxml($val,$dom,$itemx);}}header(‘Content-Type:text/xml‘);dump($dom->saveXML());}//get id 擷取內容,調用json方法public function find(){$id = $_GET[‘id‘];//接收id$User = M(‘user‘);//$val->where("id = $id")->select();$data=$User->where( "id = $id" )->find();$this->json($data);//dump($val);//dump($id);}//封裝json方法public function json($data){foreach($data as $key=>$value){$jobj->$key=$value;}//print_r($jobj);//列印傳遞屬性後的對象//echo ‘使用$jobj->row[0][\‘code\‘]輸出數組元素:‘.$jobj->row[0][‘code‘].‘<br>‘;echo ‘編碼後的json字串:‘.json_encode($jobj).‘<br>‘;//列印編碼後的json字串}//get id and account 獲得內容並顯示出來public function un(){$account = $_GET[‘account‘];//接收account$id=$_GET[‘id‘];//接收密碼$User = M(‘user‘);//$condition = new stdClass(); $condition[‘account‘] = $account;$condition[‘id‘] = $id;//$val->where("id = 1")->select();$User->where($condition)->find();//$this->json($data);dump($_GET);dump($User);dump($condition);}//get account and password,調用json方法public function up(){$account = $_GET[‘account‘];//接收account$password=$_GET[‘password‘];//接收密碼$User = M(‘user‘);//$condition = new stdClass(); $condition[‘account‘] = $account;$condition[‘password‘] = $password;//$val->where("id = 1")->select();$data=$User->where($condition)->find();//$this->json($data);//dump($_GET);//dump($User);//dump($condition);$this->json($data);}

 

thikphp 簡單的介面骨架

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.