Home > Backend Development > PHP Tutorial > php判断url连接,然后给一个变量赋值,该如何处理

php判断url连接,然后给一个变量赋值,该如何处理

WBOY
Release: 2016-06-13 10:46:03
Original
1200 people have browsed it

php判断url连接,然后给一个变量赋值
php判断当前url,

如:
www.xxx.com/jc/
www.xxx.com/ww/
www.xxx.com/cc/

当url为jc的时候,$gid=80
当url为ww的时候,$gid=52
当url为cc的时候,$gid=12


.....


请问下该如何写这个php,新手学习,多多帮助

------解决方案--------------------

PHP code
switch($_SERVER["REQUEST_URI"]){case '/jc/':$gid=80;break;case '/ww/':$gid=52;break;case '/cc/':$gid=12;break;default:$gid=0;break;}<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template