简体   繁体   English

php if (($ _ SERVER ['REQUEST_URI'])

[英]php if (($ _ SERVER ['REQUEST_URI'])

I want to create a condition for any pages that will be here: / user / The pages themselves can have any name.我想为这里的任何页面创建一个条件:/用户/页面本身可以有任何名称。

I have an example like this:我有一个这样的例子:

if(($_SERVER['REQUEST_URI']) =='/user/index.html') { echo 'class="userlog"'; }

But it only works on a specific page (in this case index.html)但它只适用于特定页面(在本例中为 index.html)

How to be?怎样成为?

Try this:尝试这个:

if(($_SERVER['REQUEST_URI']) == '/user/' . basename(__FILE__)) { echo 'class="' . basename(__FILE__, '.php') . '"'; }

Check the result of global variable $_SERVER['REQUEST_URI'] and use .php in the files extensions.检查全局变量$_SERVER['REQUEST_URI']并在文件扩展名中使用.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM