Warning: preg_match() [function.preg-match]: Unknown modifier '/' problem
- by SonOfOmer
I am building custom implementation of php MVC routing engine, and I have custom routes like one in $routes array below.
Each time when I send asynchronous GET request like xmlhttp.open("GET","someurl"); I get following message
Warning: preg_match() [function.preg-match]: Unknown modifier '/' problem
but with synchronous (normal) request it all works fine
<?php
$routes = array(
array('url' => '/^someurl$/', 'controller' => 'somecontroller', 'view' => 'someview')
);
$url = $_SERVER['REQUEST_URI'];
$url = substr( $url, 1 );
$params = array();
$route_match = false;
foreach($routes as $urls => $route)
{
if(preg_match($route['url'], $url, $matches))
{
$params = array_merge($params, $matches);
$route_match = true;
break;
}
}
require_once(CONTROLLER_PATH.$route['controller'].'.php');
?>
string(11) "/^someurl$/" is the result of var_dump($route['url']);
Thanks.