mrherman Posted July 20, 2010 Share Posted July 20, 2010 Upgraded to 5.3, so I'm trying to make sure that all vars are set. To do this, I have an "include" file that sets the value of a bunch of vars to 0 (zero). Then I have another include file that echos the values of the, so far, unchanged variables. I would expect the output to be that each var would be equal to 0. But, no. I get a ton of error messages that the vars are undefined. So, does include file "B" know what include file "A" did? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/208350-upgraded-to-53-setting-the-value-of-a-variable-with-include-file/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 20, 2010 Share Posted July 20, 2010 Post your code that demonstrates the problem, showing the opening php tag being used in each file. Quote Link to comment https://forums.phpfreaks.com/topic/208350-upgraded-to-53-setting-the-value-of-a-variable-with-include-file/#findComment-1088845 Share on other sites More sharing options...
mrherman Posted July 20, 2010 Author Share Posted July 20, 2010 Well, since you seem to suggest that it should be working, I wrote a simple script: MAIN.PHP <?php include "include_1.php" ; include "include_2.php" ; ?> INCLUDE_1.PHP <?php echo "you are at include_1.php" . "<br />; $mycolor = "blue" ; ?> INCLUDE_2.PHP <?php echo "you are at include_2.php" . "<br />" ; echo "mycolor = " . $mycolor ; ?> ...and the output is: you are at include_1.php you are at include_2.php mycolor = blue So, it does work and the issue is my crappy code. Well, let me look further before I give completely up. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/208350-upgraded-to-53-setting-the-value-of-a-variable-with-include-file/#findComment-1088866 Share on other sites More sharing options...
mrherman Posted July 21, 2010 Author Share Posted July 21, 2010 Isolated my problem. The line invoking the include file that reset all the variables was located in the wrong place. Hence, the unset variables. I gotta go. Quote Link to comment https://forums.phpfreaks.com/topic/208350-upgraded-to-53-setting-the-value-of-a-variable-with-include-file/#findComment-1088883 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.