Jump to content

globals


jagguy

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.