开发者

Getting controller name and action name from url

开发者 https://www.devze.com 2023-01-12 15:09 出处:网络
I\'m searching for an easy way to \"translate\" url strings into arrays of controller/action name pairs.

I'm searching for an easy way to "translate" url strings into arrays of controller/action name pairs.

example1:

/users/
开发者_如何学Python

should return

array('controller'=>'users','action'=>'index')

example2:

/admin/users/view/23

should return

array('controller'=>'users','action'=>'admin_view')

example3:

/

should return

array('controller'=>'pages','action'=>'home')


Router::parse could do it.

E.g.:

 <?php debug(Router::parse('/admin/users/index')) ?>

It is not exactly what you described, but chances are that this format is even better for further use, if you "stay" in cake.

0

精彩评论

暂无评论...
验证码 换一张
取 消