0

您好 $mostamazingforumforfastanswersever。

我有一个愚蠢的问题;写这个的最好方法是什么:

if ($curpageurl == "www.mysite.com/this" || "www.mysite.com/this/")

{
echo 'this is the this page'; 
}

如果不是,那么我需要打电话

while (isset($somevariable)
{
echo '$somevariable';
}

如果该变量未设置并且我们不在此页面上,那么

else 
{
echo 'we are not on this page and the variable isn't set';
}

我知道我离正确答案不远了,这实际上是按原样工作的,但前提是我删除了 || 我的第一个 if 语句的 this/ 部分。有没有更好的方法来编写或等于部分?|| == 例如?谢谢!

4

2 回答 2

0
if ($curpageurl == "www.mysite.com/this" || $curpageurl == "www.mysite.com/this/")
于 2009-12-05T19:47:36.773 回答
0

如果你只是因为 / 这样做,也许最简单的方法就是使用 substr 或类似的东西来获得你想要的部分。

所以检查最后一个字符是否是 /,如果是,则将 $curpageurl 获取到最后一个字符 -1

我只是建议您这样做,以防您对 $curpageurl 有更多可能的值

于 2009-12-05T19:54:56.093 回答