我正在使用CakePhp 2.5,如何使用$this->referer()
获取控制器和操作,而不必使用php explode函数。
(int) 0 => 'http:',
(int) 1 => '',
(int) 2 => 'localhost',
(int) 3 => 'mysite',
(int) 6 => 'books',
(int) 7 => 'list'
我的目标是在生产和本地开发中使用相同的代码。
如果我确实使用爆炸,那么本地的索引可能与生产不同。
答案 0 :(得分:1)
您可以使用$url = CakeRoute::parse($this->referer());
方法将字符串反转为数组。
https://book.cakephp.org/2.0/en/development/routing.html#CakeRoute::parse
?