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. Link to comment https://forums.phpfreaks.com/topic/139493-splitting-url-into-array-in-bootstrap-file/ 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/ Link to comment https://forums.phpfreaks.com/topic/139493-splitting-url-into-array-in-bootstrap-file/#findComment-729770 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.