Jump to content

Archived

This topic is now archived and is closed to further replies.

pneudralics

Just a little help with explaining

Recommended Posts

// MEMBERS COOKIE
$VAR[4] = "";

can someone explain how var4 works? what does it do when it writes to the cookie?
Is $VAR global or the coder have to set what the value is?

Thanks in advance.

Share this post


Link to post
Share on other sites
Hi,

that single line of code does not expain everything but here goes:

$VAR[4] is an array, and on it just takes any values you assign to it. I'm guessing that the line is just for initialization of a config or something. Writing to the cookie does not happen here but on some other line, it just sets the value to the array and write its content later on to the cookie, try searching for "setcookie(", its the actual function that writes the contents of the variable to the cookie.

Your other question, if is $VAR a global variable, depends on where you find that line, if it is outside any function or class, it is a global variable, and also, if your PHP ini's global variable is set to YES, then its definitely global.

hope that helps.

Share this post


Link to post
Share on other sites
PHP doesnt have a global variable called $VAR. $VAR is set in your script somewhere which might holds a users name in $VAR[4] and then sets a cookie which stores the username of the user.

In order to understand where $VAR[4] is set or how it is being created I (or we) cant really tell you how $VAR is set or what it is doing. You wont be able to find $VAR anywhere at php.net as its not a predifined (global) variable.

Share this post


Link to post
Share on other sites

×

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.