spaze Posted January 5, 2009 Share Posted January 5, 2009 Hello all, I am working on my own framework for certain reasons and just wanted to know what is the best way to split given URL into an array from which I would build the function. So far I have: $service_dirs = explode('/', $_SERVER["REQUEST_URI"]); $controller, $action, $obj = ''; if ($service_dirs) { if ( $service_dirs[2] ) { $controller = $service_dirs[2]; } if ( $service_dirs[3] ) { $action = $service_dirs[3]; } if ( $service_dirs[4] ) { $obj = $service_dirs[4]; } } What would be a better approach to this. I have a bootstrap file index.php to which all traffic is directed. Then the index.php calls for certain controllers based on the given URL: www.mydomain.com/view/user/1234 In the above example I would call the view controller and userAction with userid 1234. Quote Link to comment Share on other sites More sharing options...
vbnullchar Posted January 5, 2009 Share Posted January 5, 2009 http://snipplr.com/view/6526/split-an-url-into-protocol-site-and-resource-parts/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.