2012-07-24 65 views
1

我有下面的代码

function redireectIfNeeded(){ 
$url = $_SERVER["REQUEST_URI"]; 
if(preg_match("/\.php/$", $url)) 
    header("Location: ".preg_replace("/\.php/",$url)); 
} 

这是给我下面的错误。

[24-Jul-2012 19:14:18] PHP Warning: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Unknown modifier '$' in ../dbc.php on line 223 

我知道我需要一个分隔符的地方,但没有任何我尝试过的。任何人都可以让我知道我需要做什么吗?

回答

5

您必须设置$前/

if(preg_match("/\.php$/", $url)) 
    header("Location: ".preg_replace("/\.php/",$url)); 
} 

分隔符可以使用变质(S,M或i)

+0

感谢堆后!会标记它何时让我。 :) – dpDesignz 2012-07-24 07:20:46

相关问题