2013-03-13 293 views
0

我希望得到任何的URL有index.php?route=forum/在他们匹配部分

范例网址过滤所有的比赛有:

http://test.codetrove.com/index.php?route=forum/forum

http://test.codetrove.com/index.php?route=forum/forum_category&forum_path=2

所以我需要如果匹配包含index.php?route=forum/,那么http和domain可以是任何类似http或https或任何域的匹配。

任何想法的?

+0

是有没有简单的检查,如果$ _GET [ '路线']开头'forum'理由吗? – hexblot 2013-03-13 15:42:26

+2

if(strpos($ url,“index.php?route = forum /”)!== false)// if if found == true – Sturm 2013-03-13 15:42:27

+0

preg_match()怎么样? – egig 2013-03-13 15:43:11

回答

1

不是使用棒球棍打棍子蜘蛛,看看strpos()。

$string = "index.php?route=forum/"; 
if (strpos($url, $string) !== false) { 
    //we have a match 
} 
1

您可以使用正则表达式:

/index\.php\?route=forum\/.*/ 

或用$ _GET变量

if(preg_match('/forum\/.*/', $_GET['route'])) { 
    echo 'yahoo'; 
} 
0

一种可能性是使用PHP strpos功能记录here

$IsMatch = strpos ($url , "index.php?route=forum/"); 
+0

在两侧用backtics(')环绕它。 – merlin2011 2013-03-13 15:47:16