2013-03-13 279 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