jagguy Posted July 12, 2007 Share Posted July 12, 2007 Hi, I want to have a variable set in 1 script that can be used in all other scripts eg a global variable. I need a global variable to tell me if someone has logged in from every page and the url the site is located on for header redirects. I don't understand $GLOBAL and i tried $my_var="http://dog"; global $my_var; and echo $my_var in another script as it fails. Link to comment https://forums.phpfreaks.com/topic/59610-globals/ Share on other sites More sharing options...
JasonLewis Posted July 12, 2007 Share Posted July 12, 2007 the global command is used to grab variables that are outside, for example, a function. to make it global you could use the $_SESSION global and then have session_start() at the top of each page. session_start(); $_SESSION['my_var'] = "http://dog"; echo $_SESSION['my_var']; read up about sessions... Link to comment https://forums.phpfreaks.com/topic/59610-globals/#findComment-296452 Share on other sites More sharing options...
trq Posted July 12, 2007 Share Posted July 12, 2007 The $GLOBAL array holds a list of all variables within the current scripts scope. there is no such thing as a site wide $GLOBAL. As has been posted, its sessions your looking for. Link to comment https://forums.phpfreaks.com/topic/59610-globals/#findComment-296460 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.