Jump to content

PHP variables


ryan.od

Recommended Posts

How does PHP treat variables? What I mean is, if I set $auth = 1 in one script and then set $auth = 0 in another script, which value does the site recognize as the true value? Is each $auth unique to it's script (local) or are variables in PHP such as the $auth variable I am using global?

Thanks.

ryanod
Link to comment
Share on other sites

Okay so basically, it's how jwk811 put it, but theres a little more to it.  To put it clearly:

let's say i have a variable named $str.

up at the top of my file, $str = "Eric Cartman";

let's say I want to change the value of $str later in my script:  $str = "Stan Marsh";

but also, using the "." operator, i could add things to a string: $str .= " and Kenny McCormick";

which would echo "Eric Cartman and Kenny McCormick"

plus, if you include a file that contains a variable in another file, the variable is accessible in the file you included it to.
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.