REGEX BUG : if a parameter is optionnal in the regex, don't show an error

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1263 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-03-26 20:33:14 +00:00
parent 7c2ea07315
commit 4e34002ffe

View File

@@ -537,6 +537,8 @@ class route
// URL === REGEXP ROUTE
// Variables are exposed in url/{var1}/{var2}
$regex = "#^$route$#U";
//$regex = str_replace ("?", "\?", $regex);
//$regex = str_replace (".", "\.", $regex);
$regex = str_replace ("{", "(?P<", $regex);
$regex = str_replace ("}", ">.+)", $regex);
unset ($matches);
@@ -548,7 +550,12 @@ class route
$params = array ();
$reflect = new ReflectionFunction ($function);
foreach ($reflect->getParameters() as $key=>$val)
$params[] = $matches[$val->name];
{
if (isset ($matches[$val->name]))
$params[] = $matches[$val->name];
else
$params[] = null;
}
call_user_func_array ($function, $params);
exit;
}