php杂记

1.php获取POST内容:

以下php代码想要获取post内容的话,

<?php
 echo $_POST['name'];
 echo "</br>";
 echo $_POST['tel'];
?>

需要保证http数据包里包含:Content-Type: application/x-www-form-urlencoded

比如以下数据包:

POST /dev/post.php HTTP/1.1
Host: 192.168.1.120
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
DNT: 1
Cookie: PHPSESSID=a2jvp67df5m0borojak40ocfr3
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 23

name=user&tel=110

 

上一篇
下一篇