今天就跟大家聊聊有關(guān)使用php怎么接收和處理 post、json參數(shù),可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。
1.php
<? function http_post_data($url, $data_string) { $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json; charset=utf-8', 'Content-Length: ' . strlen($data_string)) ); ob_start(); curl_exec($ch); $return_content = ob_get_contents(); //echo $return_content."<br>"; ob_end_clean(); $return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); // return array($return_code, $return_content); return $return_content; } $url = "http://127.0.0.1/2.php"; $data = json_encode(array('a'=>"weqweqwe", 'b'=>2)); //list($return_code, $return_content) = http_post_data($url, $data); $aaa = http_post_data($url, $data); //print_r($aaa); echo $aaa; $ccc=json_decode($aaa); print_r($ccc); echo $ccc->b; echo "<hr>"; $json = '{"a":1,"b":2,"c":3,"d":4,"e":5}'; var_dump(json_decode($json,true)); ?>
頁面2,參數(shù)接收處理:
2.php
<? $postData = file_get_contents('php://input'); echo $postData; $data = json_encode(array('a'=>" 234 ", 'b'=>2)); echo $data; ?>
一、phpStudy,是一個新手入門最常用的開發(fā)環(huán)境。二、WampServer,WampServer也同樣的也是和phpStudy一樣操作簡單對小白比較友好。三、XAMPP,XAMPP(Apache+MySQL+PHP+PERL)是一個功能強(qiáng)大的建站集成軟件包;四、MAMP,MAMP分為兩種MAMP和MAMP Pro for Mac。五、寶塔面板,寶塔面板是一款服務(wù)器管理軟件,支持windows和linux系統(tǒng)。六、UPUPW,UPUPW是目前Windows平臺下最具特色的Web服務(wù)器PHP套件。
看完上述內(nèi)容,你們對使用php怎么接收和處理 post、json參數(shù)有進(jìn)一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。
文章標(biāo)題:使用php怎么接收和處理post、json參數(shù)-創(chuàng)新互聯(lián)
文章路徑:http://jinyejixie.com/article12/cshodc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、App設(shè)計(jì)、標(biāo)簽優(yōu)化、網(wǎng)站制作、定制開發(fā)、微信公眾號
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容