? ?? ???? ???? ??? ?? ??? ??? ???. ?? PHP ??? ???? ? ? ?? ???? ???? ?? ??? ? ??? ?? ? ?????. ? ????? ThinkPHP5 ??????? ???? ??? ???? ??? ?????.
1. ?? ??
ThinkPHP5 ?????? GET, POST, PUT, DELETE ? ?? HTTP ?? ??? ?????. ? ?? ???? ?? ??? ????. ??? PHP? ?? CURL ?????? ???? ???? ???, ?? ??? ThinkPHP5 ?????? ?? HTTP ??? ?????? ???? ???? ????.
1. ?? CURL ?????? ???? ??
CURL ?????? ???? ???? ??? ?? ?? ?? ????? ???? ???? ?? ??? ?? ? ?? ?? ????? ???? ?????. ??? ???? CURL ?????? ???? GET ??? ?? ?? ?????.
$url = 'http://www.example.com'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); echo $output;
? ????? CURL ??? ?_init() ??? ?? ???? ?? CURL ??? ??? ?_setopt(? ?? ?????. ) ??? ???? ????? ?_exec() ??? ?? ??? ???? ?? ??? ????. ??? ??? ?, curl_close() ??? ?? CURL ??? ????.
- ThinkPHP5 ?????? ??? HTTP ??? ?????? ???? ?????
ThinkPHP5 ?????? ??? HTTP ??? ?????? ???? ???? ??? ? ???? ??? ? ??? HTTPS ????? ?? ??? ?????. ??? HTTP ??? ?????? ???? GET ??? ???? ?? ?????.
use thinkacadeHttp; $url = 'http://www.example.com'; $response = Http::get($url); echo $response->getBody();
? ????? ?????? ??? HTTP ??? ?????? ???? GET ??? ?????. Http::get() ???? URL ????? ???? ?? ??? ????, getBody() ???? ?? ?? ??? ???.
2. ?? ????
???? ?? ? ???? ??? ???? ?? ??? ????. ??? POST ??? ???? ?? ????.
- ???? CURL ?????? ???? POST ?? ???
???? CURL ?????? ???? POST ??? ??? ??, ?_setopt() ??? ???? CURLOPT_POST ??? ???? ???? ??? ??? ???? ???. . ??? ???? CURL ?????? ???? POST ??? ???? ?? ?????.
$url = 'http://www.example.com'; $data = array('name' => 'John Doe', 'email' => 'johndoe@example.com'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); echo $output;
? ????? ?_setopt() ??? ???? CURLOPT_POST ??? ???? POST ??? ????? ???? ??? ?????. CURLOPT_POSTFIELDS ??.
2. ThinkPHP5 ?????? ??? HTTP ??? ?????? ???? POST ?? ???
HTTP ??? ?????? ???? POST ??? ?? ? $post ????? ?? ???? ??? ???? ???. ??? HTTP ??? ?????? ???? POST ??? ???? ?? ?????.
use thinkacadeHttp; $url = 'http://www.example.com'; $data = array('name' => 'John Doe', 'email' => 'johndoe@example.com'); $response = Http::post($url, $data); echo $response->getBody();
? ????? Http::post() ???? ???? ?? ?? ??? $data ?? ??? ?? ?????.
3. ?? ??
???? ??? ??? ?, ?? ??? ?? ?? ??? ??? ???. ???? ?? ??? ???? ??? ??? ????.
1. ?? ??? ?? CURL ?????? ?????
?? ??? ?? CURL ?????? ??? ??, ?_exec() ??? ?? ?? ??? ?? ? ???? ?? ??? ?? ??? ?? ???? ???. ??? ?? ??? ?? CURL ?????? ???? ?? ?????.
$url = 'http://www.example.com'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); $result = json_decode($output, true); echo $result['data']['name'];
? ????? ?? ??? ?? ?? ?_exec() ??? ???? ??? ?? ???? ? json_decode() ??? ?????.
2. ?? ??? ?? ThinkPHP5 ?????? ??? HTTP ??? ?????? ?????
?? ??? ?? HTTP ??? ?????? ??? ? ?? ??? ?? ????? ?? ??? ?? ?? ? ????. ??? ?? ??? ?? HTTP ??? ?????? ???? ?? ?????.
use thinkacadeHttp; $url = 'http://www.example.com'; $response = Http::get($url); $result = $response->json(); echo $result['data']['name'];
? ????? Http::get() ???? ???? ?? ??? ???? ? ??? ??? ?? ??? ?? ?????. $response->json() ???.
4. ?? ??
???? ?? ???? ???? ???? ?? ?? ?? ??? ??? ? ???? ?? ??? ?????. ??? ???? ?? ? ???? ?? ?? ?????.
1. ?? ??? ?? CURL ?????? ?????
?? ??? ?? CURL ?????? ??? ? ??? ????? ????? ??? ?? ?? ???? ???. ??? ?? ??? ?? CURL ?????? ???? ?? ?????.
$url = 'http://www.example.com'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); if (curl_errno($ch)) { echo 'Error: ' . curl_error($ch); } else { $result = json_decode($output, true); echo $result['data']['name']; } curl_close($ch);
? ????? CURL ?? ?? ?? ??? ?? ?? ?_errno() ??? ???? ??? ?? ?? ?_error() ??? ?????. ??.
2. ?? ??? ?? ThinkPHP5 ?????? ??? HTTP ??? ?????? ?????
?? ??? ?? HTTP ??? ?????? ??? ? try...catch ?? ?? ??? ??? ???. ??? ?? ??? ?? HTTP ??? ?????? ???? ?? ?????.
use thinkacadeHttp; $url = 'http://www.example.com'; try { $response = Http::get($url); $result = $response->json(); echo $result['data']['name']; } catch (Exception $e) { echo $e->getMessage(); }
? ????? try...catch ?? ???? HTTP ?? ? ??? ???? getMessage() ???? ???? ??? ?????. ?? ??.
??
???? ??? ? ?? ?????? ???? ?? ?????. ???? ??? ???? ???? ??? ??? ?? ?? PHP ? ?? ?????? ???? ?? ? ?????. ? ????? ?? ???, ?? ????, ?? ?? ? ?? ??? ???? ThinkPHP5 ??????? ???? ??? ???? ??? ?????. ??? ???? ????.
? ??? thinkphp5 ???? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)