Reputation: 433
I want to get one page variable values to another page. Is it possible to do with $GLOBALS? or else how should i do? I have a variable
$url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
I want to access $url from another file.
Upvotes: 0
Views: 42
Reputation: 758
In my experience, the most common way is to store it is a $_SESSION, $GLOBALS won't persist between your pages.
An example of Session usage
$_SESSION['url'] = $url;
or $_SESSION['url'] = 'http:// . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
As long as your session is initiated you'll have access, and for large amounts of data, you may want to serialize it before moving it to a Session.
Upvotes: 1