irken Posted April 15, 2007 Share Posted April 15, 2007 Hello. I have the following piece of code: if (isset($_GET['q'])) { $params = explode('/', trim(stripslashes($_GET['q']))); @list($plugin, $function) = $params; # index.php?q=test/add # index.php?q=test/del if (isset($plugin) && isset($function)) { $plugin_path = './plugins/' . strtolower($plugin) . '/' . strtolower($function) . '.php'; if (is_file($plugin_path)) { @include_once $plugin_path; exit; } } # index.php?q=test if (isset($plugin) && !isset($function)) { $plugin_path = './plugins/' . strtolower($plugin) . '.php'; if (is_file($plugin_path)) { @include_once $plugin_path; exit; } } } else { // Show front page.. } What this does is allow me to write for example: index.php?q=test - to include the file located at ./plugins/test.php index.php?q=test/add - to include the file located at ./plugins/test/add.php And so forth. I'm looking for a more dynamic way of doing this. What if I need to have yet another parameter for articles perhaps. index.php?q=article/view/01 That would require me to make yet another if expression and expand the list statement: @list($plugin, $function) = $params; if (isset($plugin) && isset($function) && isset($article_id)) { .. } Is there a way around this? Perhaps even a better way. It's not very dynamic if I have to change my functions each time I need to add a feature and/or module and would result in like 50 if checks. Thanks for reading. 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.