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? Link to comment https://forums.phpfreaks.com/topic/105853-ways-of-passing-data-to-included-page/ 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"); Link to comment https://forums.phpfreaks.com/topic/105853-ways-of-passing-data-to-included-page/#findComment-542530 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.