Good afternoon, I am writing a simple router.

Several routes are registered in the router, so the following code is executed through a loop that goes through the routes.

preg_match(Router::$_regex[$key],$uri, $result); var_dump($result); if( empty($result) ) return false; 

Router::$_regex[$key] is a regular - |^test/id$|is

If a person enters the correct URL (site.ru/test/id), then skip it further.

If the regular is another, then we stop this circle in the cycle and go on to check

But how to make it so that if a person entered site.ru/test/id/blabla/bla then an error was displayed? I get a return false; although it should work only in the second case ...

  • so what's the problem ? If you do not have the appropriate regulars (no regulars match), then this address does not exist and you need to show an error. - Alex Kapustin
  • Solution found. - infolabs

1 answer 1

I understand you do not need just a dollar, indicating the end of the line

 |^test/id|is