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? 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 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. Link to comment https://forums.phpfreaks.com/topic/112718-help-with-global-variables/#findComment-578886 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.