php variables

In PHP you can’t normally access a global variable within a function without either using the global keyword to call the global variable into the function or by using the globals array. Therefore, you wouldn’t be able to echo the global variables’ value inside the function. So how is it that you can change the value of the global variable within a function without the keyword or array or anything else other than the assignment you normally would do? So I can’t echo it but I can change it’s value.

You cannot change the value of a variable outside the scope of a function. When you say global variables, I assume you are talking about variables with script wide scope (IE ones you define in a script, outside of a function/class/or method.) or the super global variables that PHP supplies.

Whatever is happening that is leading you to believe that the above is the case, you are misinterpreting the results of your code.

Sponsor our Newsletter | Privacy Policy | Terms of Service