topcoder1 Posted May 16, 2008 Share Posted May 16, 2008 I know there are two ways to pass arguments to an included page. 1. declare variable in the main page, and the included page will have access to this variable by default scope. in main.php $test="hi"; <?php include("include1.php");?> 2. pass the argument from get in main.php <?php include("include1.php?test=hi");?> the second way doesn't pollute the namespace but is limited to pass simple arguments(not arbitrary objects). Is there any other way? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 16, 2008 Share Posted May 16, 2008 Method 2 does not work when including a local file. You would need to set the $_GET variable before the include() if you wanted the code to receive the variable - $_GET['test'] ="hi"; include("include1.php"); 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.