尊龙凯时人生就是博

thinkphp»ñÈ¡²»µ½postÊý¾ÝÔõÑù½â¾ö

Ò»¡¢ÎÊÌâÕ÷Ïó

Ìá½»±íµ¥ºó£¬Í¨¹ý request->param() »ò $this->request->param() »ñÈ¡²»µ½ post Êý¾Ý£¬»ñµÃµÄÊÇ¿ÕÊý×é¡£

¶þ¡¢ÎÊÌâÔµ¹ÊÔ­ÓÉ

±íµ¥ÖÐûÓÐÉèÖà enctype ÊôÐÔ

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

ÔÚ±íµ¥Ìύʱ£¬ÈôÊÇ enctype ÊôÐÔûÓÐÉèÖã¬ÄÇôĬÈϵÄÊý¾Ý´«Êä·½·¨ÊÇ application/x-www-form-urlencoded¡£ÏÖÔÚ£¬Êý¾Ý½«±»°²ÅÅÔÚ HTTP ÇëÇóÍ·²¿¶ø·ÇÇëÇóÌåÖС£ÒÔÊÇ£¬ÔÚ»ñÈ¡ post Êý¾Ýʱ£¬ÎÒÃÇÐèҪʹÓà $this->request->post() »òÕß request()->post()¡£

½Ó¿ÚŲÓÃʱûÓÐÉèÖÃÇëÇóÍ·

ÔÚ½Ó¿ÚŲÓÃʱ£¬ÎÒÃÇÐèÒªÉèÖÃÏìÓ¦µÄÇëÇóÍ·£¬ºÃ±È Content-Type£ºapplication/json£¬²»È»Ð§ÀÍÆ÷ÎÞ·¨ÆÊÎöÊý¾Ý¡£ÈôÊÇûÓÐÉèÖà Content-Type£¬ÔòЧÀÍÆ÷ĬÒÔΪ application/x-www-form-urlencoded£¬¶ø´Ëʱ post µÄÊý¾Ý»á·ÅÔÚ http ÇëÇóÍ·ÖУ¬¶ø²»ÊÇÇëÇóÌåÖУ¬µ¼ÖÂÎÞ·¨×¼È·»ñÈ¡ post Êý¾Ý¡£

Èý¡¢½â¾öÒªÁì

ÉèÖÃ enctype ÊôÐÔ

ÔÚ±íµ¥ÖÐÌí¼Ó enctype=”multipart/form-data”£¬ÕâÑù¾ÍÄܹ»×¼È·»ñÈ¡ post Êý¾ÝÁË¡£

ÉèÖÃÇëÇóÍ·

ÔÚ½Ó¿ÚŲÓÃʱ£¬¿ÉÒÔʹÓà curl ÉèÖÃÇëÇóÍ·¡£Ê¾Àý´úÂëÈçÏ£º

$data = array(
    'username' => 'admin',
    'password' => '123456'
);

$url = 'http://www.example.com/login';
$ch = curl_init();

$header = array(
    'Content-Type: application/json',
    'Content-Length: '.strlen(json_encode($data))
);

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$res = curl_exec($ch);
curl_close($ch);

µÇ¼ºó¸´ÖÆ

ÒÔÉϾÍÊÇthinkphp»ñÈ¡²»µ½postÊý¾ÝÔõÑù½â¾öµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ