1
我試圖將字符串轉換爲Zend Framework格式的URL。從字符串獲取Zend Framework URLs
例如,我有一個字符串列表
http://example.com/products/category/books
http://example.com/products/category/computers
http://example.com/contact
我想收到的Zend_Controller_Request_Http對象,其中類似的控制器,動作,參數,可以等參數將被承認的名單。
Zend_Controller_Request_Http Object (... [_params:protected] => Array ([controller] => index [action] => products [category] => books [module] => default) ...)
Zend_Controller_Request_Http Object (... [_params:protected] => Array ([controller] => index [action] => products [category] => computers [module] => default) ...)
Zend_Controller_Request_Http Object (... [_params:protected] => Array ([controller] => index [action] => contact ...)
我找到了一些解決方案here(感謝Willy Barro)
$url = 'http://example.com/module/controller/action/param1/test';
$request = new Zend_Controller_Request_Http($url);
Zend_Controller_Front::getInstance()->getRouter()->route($request);
$request->getParams();
,它的第一個URL工作正常,但其餘我收到相同的參數:
[controller]=>index, [action]=>products, [category]=>books
[controller]=>index, [action]=>products, [category]=>books
[controller]=>index, [action]=>contact, [category]=>books
外貌像所有我無法改變參數......
也許有另一種方法將字符串轉換爲zf URL。
預先感謝您!