Jump to content


Photo

Just a little help with explaining


  • Please log in to reply
3 replies to this topic

#1 pneudralics

pneudralics
  • Members
  • PipPipPip
  • Advanced Member
  • 241 posts

Posted 22 April 2006 - 07:24 AM

// 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.

#2 eves

eves
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 22 April 2006 - 02:41 PM

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.

#3 pneudralics

pneudralics
  • Members
  • PipPipPip
  • Advanced Member
  • 241 posts

Posted 22 April 2006 - 05:07 PM

Where does it list the globals for VAR[number]?
Couldn't find it at php.net

Thanks.

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 22 April 2006 - 05:40 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users