Zend框架为什么这个网址没有工作,哪个有西班牙语字符?

时间:2015-12-07 08:43:01

标签: php zend-framework zend-framework2

当我访问网址时http://www.example.com/Formación 然后路由应该匹配,但它不起作用,因为我有一个字符ó,如何使这个ó西班牙语字符与ZF中的以下路由兼容?

$route = Http\Segment::factory(array(
  'route' => '/Formación',  //<<<<< this character must be used: ó
  'defaults' => array(
    'controller' => 'Application\Controller\Trainingsignup',
    'action' => 'index'
  ),
));
$router->addRoute('traininges', $route, null); 

编辑:也失败了

  'constraints' => array(
      'controller' => '[a-zA-ZóäöüÄÖÜß][a-zA-ZóäöüÄÖÜß0-9_-]+',
      'action'     => '[a-zA-ZóäöüÄÖÜß][a-zA-ZóäöüÄÖÜß0-9_-]+',
  ),   

编辑:也失败了

  'constraints' => array(
      'controller' => '/^\p{L}[\p{L} _.-]+$/u',   //or /[\p{L}]+/u
      'action'     => '/^\p{L}[\p{L} _.-]+$/u',   //or /[\p{L}]+/u
  ), 

1 个答案:

答案 0 :(得分:1)

我诚实的回答是:不要做 - 请使用ASCII。

但如果你真的想要:How to set a (UTF8) modifier for RegEx of a RegEx Route in Zend Framework 2?