Reputation: 1959
I've got the following code
function redireectIfNeeded(){
$url = $_SERVER["REQUEST_URI"];
if(preg_match("/\.php/$", $url))
header("Location: ".preg_replace("/\.php/",$url));
}
Which is giving me the following error.
[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
I know I need a delimiter somewhere, but nothing I've tried is working. Can anyone let me know what I need to do?
Upvotes: 1
Views: 172
Reputation: 4610
You must set $ before /
if(preg_match("/\.php$/", $url))
header("Location: ".preg_replace("/\.php/",$url));
}
After delimiter you can use modificator (s, m or i)
Upvotes: 5