0
cd /var/www/html/phplearn
对于http post请求和响应。如何编写curl命令来模拟get方法?
VIM send_local_post.php
<form action=http://127.0.0.1/phplearn/do_post.php method=post>
user: <input type=text name=userName size=12/>
key: <input type=text name=PS size=12/>
<input type=submit value=login>
</form>
VIM do_post.php
<?php
$userName = $_POST["userName"];
$PS = $_POST["PS"];
echo "the name is: ".$userName."\n";
echo "key word is: ".$PS."\n";
?>
让我们模拟的方法后,在控制台卷曲。
curl -X POST -d "userName=user&PS=key" 127.0.0.1/phplearn/do_post.php
在控制台的输出是如下:
对于HTTP GET请求和响应。
VIM send_local.get.php
<form action=http://127.0.0.1/phplearn/do_get.php method=get>
user: <input type=text name=userName size=12/>
key: <input type=text name=PS size=12/>
<input type=submit value=login>
</form>
VIM do_get.php
<?php
$userName = $_GET["userName"];
$PS = $_GET["PS"];
echo "the name is: ".$userName."\n";
echo "key word is: ".$PS."\n";
?>
让我们模仿get方法与控制台卷曲。
curl http://127.0.0.1/phplearn/do_get.php?userName=user&PS=key
为什么不能显示在控制台上的键的值,如后方法?