大家否知道php可以利用header('Location')实现get请求跳转。
php利用curl可以实现模拟post请求。
但是却找不到php现成的实现post跳转。
那么问题来了,如果有这个需求该怎么实现呢?
今天在这里,利用form+js跟大家攒一个php的post跳转的方法。
index.php(发起跳转页面)
$value){
$formItemString.="";
}
//构造表单并跳转
$content=<<
{$formItemString}
EOF;
exit($content); action.php(跳转目标页面)
无图无真相,各位看官都来瞧瞧。
get访问:
http://yoururl/index.php?name=jack&age=100&sex=boy&no=001
真相在这!自动post跳转到了目标页面,且可以在目标页面里面获取到post值。
上一篇:php版本怎么选择
下一篇:PHP的FastCGI