Home  >  Article  >  Backend Development  >  How to jump according to specified parameters in php

How to jump according to specified parameters in php

藏色散人
藏色散人Original
2021-03-18 09:15:072921browse

How to implement php jump according to specified parameters: first create a PHP sample file; then define an array to save the URL to be jumped; finally pass "header('Location:' . $URl[ $ID]);" can be used to achieve the jump.

How to jump according to specified parameters in php

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php jumps to the specified URL according to the parameters

Specific question: Assume it is a.php file, URL/a.php?id=1. When id=1, it jumps to a URL. When id=2, it jumps to another specified URL?

The implementation code is as follows:

<?php
 #首先定义一个数组,用来保存要跳转的网址
 $URl = array(&#39;网址1&#39;, &#39;网址2&#39;, &#39;网址3&#39;);
 $ID  = $_GET[&#39;id&#39;];#接收id值   
 header(&#39;Location:&#39; . $URl[$ID]);

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to jump according to specified parameters in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn