jdubwelch Posted July 1, 2008 Share Posted July 1, 2008 I have two files: file #1: index.php <?php $team_id = 1; include ("test.php"); ?> file #2: test.php <?php global $team_id; echo "$team_id"; ?> I need (in the most basic form, $team_id to be a variable in test.php), however this method doesn't work. Suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/112718-help-with-global-variables/ Share on other sites More sharing options...
MasterACE14 Posted July 1, 2008 Share Posted July 1, 2008 either POST or GET the data across to the second page. ACE Quote Link to comment https://forums.phpfreaks.com/topic/112718-help-with-global-variables/#findComment-578854 Share on other sites More sharing options...
PFMaBiSmAd Posted July 1, 2008 Share Posted July 1, 2008 The global keyword has absolutely no meaning outside of a function definition (read the manual.) The posted code works (just tested), so either the include() statement failed because the path to the file is different or you would need to post your actual code to get help with what it is or is not doing. Quote Link to comment https://forums.phpfreaks.com/topic/112718-help-with-global-variables/#findComment-578886 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.