Heim  >  Artikel  >  Backend-Entwicklung  >  PHP 依据选择改变网址的参数

PHP 依据选择改变网址的参数

WBOY
WBOYOriginal
2016-06-13 12:04:181076Durchsuche

PHP 根据选择改变网址的参数
例如
                    家教
                    模特
                    派单
                    文员

                    石排
                    企石
                    横沥
                    桥头
                    谢岗
                    东坑
                    常平
而网址有两个参数:http://www.aaa.com?type=0&town=企石

当我选了桥头,网址就变成http://www.aaa.com?type=0&town=桥头
当我先了桥头+文员,网址就变成http://www.aaa.com?type=3&town=桥头

这用PHP如何实现呢?
------解决方案--------------------
建議參數全部用數字,如果沒有參數,可以默認不出或者只出第一個

<br />$types = array('<a href="" style="color:;">家教</a>','<a href="" style="color:;">模特</a>','<a href="" style="color:;">派单</a>','<a href="" style="color:;">文员</a>');<br />$towns = array('<a href="" style="color:;">石排</a>','<a href="" style="color:;">企石</a>','<a href="" style="color:;">横沥</a>','<a href="" style="color:;">桥头</a>','<a href="" style="color:;">谢岗</a>','a href="" style="color:;">东坑</a>','<a href="" style="color:;">常平</a>');<br /><br />$type = isset($_GET['type'])? intval($_GET['type']) : 0;<br />$town = isset($_GET['town'])? intval($_GET['town']) : 0;<br /><br />if(isset($types[$type])){<br />	echo $types[$type];<br />}<br /><br />if(isset($towns[$town])){<br />	echo $towns[$town];<br />}<br />


http://www.aaa.com?type=1&town=2
輸出
模特
横沥

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn