php 实现页面跳转

在php中我们可以使用header方法来实现页面的跳转,如:

$url = 'http://www.wj0511.com';
header("Location: " . $url);
exit();

使用header方法可以实现页面跳转,但是只支持get跳转,当我们需要实现post跳转的话,使用header方法就无法实现了,这时候我们可以在php中执行js跳转来实现post跳转,如:

$url = 'http://www.wj0511.com';
echo <<<EOT
<form name='test' action='{$url}' method='POST'>
</form>
<script type='text/javascript'>
    document.test.submit();
</script>
EOT;
exit;

如上我们就可以实现post跳转功能了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章