brown2005 Posted March 24, 2006 Share Posted March 24, 2006 can i not useinclude('index.php?page=login');as it doesnt work? Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted March 24, 2006 Share Posted March 24, 2006 i don't think you can pass URL parameters to an include, as i think the way includes work is to pull all of the files together into one long script before PHP parses it. so if index.php was:[code]<?phpecho $_GET['page'];?>[/code]and your main.php page that includes it was:[code]<?phpinclude('index.php?page=login');echo 'hello world';?>[/code]then PHP would pull it all the bits of main.php together before parsing it:main.php:[code]<?phpecho $_GET['page'];echo 'hello world';?>[/code]but as main.php has no URL vars, $_GET['page'] doesnt refer to anything. what you CAN do though, if you need to, is to set a variable before you include it. this will be automatically available to your include:index.php:[code]<?phpecho $page;?>[/code]main.php:[code]<?php$page = "login";include('index.php');?>[/code]would make this, which would work:main.php:[code]<?php$page = "login";echo $page;?>[/code] 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.