首頁  >  文章  >  後端開發  >  php如何實現提交後跳轉?

php如何實現提交後跳轉?

coldplay.xixi
coldplay.xixi原創
2020-07-17 10:59:132871瀏覽

php實作提交後跳轉的方法:先定義【redirect()】跳轉函數;然後調整跳轉所需的秒數,並指定跳到的位址即可,程式碼為【function redirect($ms ='', $url='', $text='')】。

php如何實現提交後跳轉?

php實作提交後跳轉的方法:

先定義【redirect()】跳轉函數,此函數是用來在使用者操作後,頁面會根據要求跳到指定頁面;然後調整跳轉所需的秒數,並指定跳到的位址即可。

<?php
/**
* 定义redirect()跳转函数,是用来在用户操作后,页面根据要求跳转到指定页面
*
* @param unknown_type $ms 是用来调整跳转所需要的秒数
* @param unknown_type $url 是指定跳转到的地址
* @param unknown_type $text 是显示跳转时候的信息
*/
function redirect($ms =&#39;&#39;, $url=&#39;&#39;, $text=&#39;&#39;){
echo <<<EOT
<meta http-equiv="refresh" content=$ms;URL=$url>
<div align="center">
<table width="600" border="0" cellpadding="1" cellspacing="1" class="tableoutline">
<tr>
   <td colspan="3"><table width="100%" border="0" cellpadding="5" cellspacing="1">
       <tr>
      <td valign="bottom"><div align="center">页面操作提示</div></td>
      </tr>
       <tr>
      <td><div align="center">$text</div></td>
      </tr>
       <tr>
      <td><div align="center"><a href="$url" mce_href="$url">本页面在 $ms 秒后自动跳转,如果您的浏览器没有跳转,点此链接返回。</a></div>
   </td>
      </tr>
   </table></td>
</tr>
   </table>
   </div>
EOT;
}
?>

相關學習推薦:PHP程式設計從入門到精通

以上是php如何實現提交後跳轉?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn