phalcon: 項目地址/P(.*) 與 路由緩存
有一個項目地址:因客戶渠道不一樣,帶的參數也不相同。當時想到的是僞靜態規則,可是發現本身沒有那麼強大。該走phalcon路由規則,地址以下:
www.xxx.com/Pbaidu
www.xxx.com/Psohu
www.xxx.com/Psansungcookie
接受P(.*),P後面的數據爲參數,獲取後cookie緩存/session緩存,那麼路由規則:session
$di->set('router', function () { $router = new Router(); $router->add("/P(.*)", array( 'controller' => 'index', 'action' => 'index', 'code' => 1 )); return $router; });
那麼獲取參數,又是一頭霧水,後來通過孜孜不倦的測試,獲取的參數的方法以下:測試
var_dump($this->dispatcher->getParam('code')); var_dump( $this->getParam('code') ); var_dump($_GET);exit; 最終: $this->dispatcher->getParam('code'); 能獲取數據
記錄一下。this