trq Posted October 26, 2009 Share Posted October 26, 2009 Read my posts. In particular this one. Quote Link to comment https://forums.phpfreaks.com/topic/178913-parameter-passing-issue-on-function/page/2/#findComment-944402 Share on other sites More sharing options...
Azarian Posted October 26, 2009 Author Share Posted October 26, 2009 Read my posts. In particular this one. I can read it a million types still not going to make the code work properly! Quote Link to comment https://forums.phpfreaks.com/topic/178913-parameter-passing-issue-on-function/page/2/#findComment-944416 Share on other sites More sharing options...
trq Posted October 26, 2009 Share Posted October 26, 2009 The code in my post does not work as you describe. I'm not sure you get what I am saying at all. How exactly does my code end up trying to call action_Action_somefunction ? Its not, unless you pass ?page=action_somefunction through the url. But, as I said, the urls should remain as they always where using my code. eg; ?page=foo would execute actionFoo(). Quote Link to comment https://forums.phpfreaks.com/topic/178913-parameter-passing-issue-on-function/page/2/#findComment-944419 Share on other sites More sharing options...
trq Posted October 26, 2009 Share Posted October 26, 2009 An example. test.php <a href="?page=foo>foo</a> <a href="?page=bar>bar</a> <a href="?page=bob>bob</a> <?php function actionFoo() { echo "This is foo"; } function actionBar() { echo "This is bar"; } function actionBob() { echo "This is bob"; } function actionWelcome() { echo "this is welcome"; } if (!isset($_GET['page']) || empty($_GET['page']) { actionWelcome(); } else { $menu_link = 'action' . ucfirst($_GET['page']); if (is_callable($menu_link)) { $menu_link(); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/178913-parameter-passing-issue-on-function/page/2/#findComment-944421 Share on other sites More sharing options...
Azarian Posted October 26, 2009 Author Share Posted October 26, 2009 The code in my post does not work as you describe. I'm not sure you get what I am saying at all. How exactly does my code end up trying to call action_Action_somefunction ? Its not, unless you pass ?page=action_somefunction through the url. But, as I said, the urls should remain as they always where using my code. eg; ?page=foo would execute actionFoo(). Ah! Ok you weren't that clear before about the URL that is the issue. This code works now. function main_page(){ if (!isset($_GET['page']) || empty($_GET['page'])) { $menu_link = action_welcome_page; $menu_link(); }else{ $menu_link = 'action_' . ucfirst($_GET['page']); if (is_callable($menu_link)) { $menu_link(); } } } Quote Link to comment https://forums.phpfreaks.com/topic/178913-parameter-passing-issue-on-function/page/2/#findComment-944422 Share on other sites More sharing options...
trq Posted October 26, 2009 Share Posted October 26, 2009 Ah! Ok you weren't that clear before about the URL that is the issue. This code works now. You are kidding me? Then, your url's would be unchainged from your previous code. eg; ?page=foo would execute actionFoo(). Maybe you just didn't read that part? Sometimes helping out here is like banging my head on a wall. Quote Link to comment https://forums.phpfreaks.com/topic/178913-parameter-passing-issue-on-function/page/2/#findComment-944424 Share on other sites More sharing options...
Azarian Posted October 26, 2009 Author Share Posted October 26, 2009 You are kidding me? Of course! LOL Quote Link to comment https://forums.phpfreaks.com/topic/178913-parameter-passing-issue-on-function/page/2/#findComment-944429 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.