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

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

WBOY
WBOYOriginal
2016-06-13 10:46:031152browse

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>
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