[nycphp-talk] Difference between the CONSTANT and the GLOBAL VARIABLE ??
David Krings
ramons at gmx.net
Sat Jun 23 16:10:10 EDT 2007
Shadab Wadiwala wrote:
> Hi, community !!
>
>
> Can somebody make me understand what is the difference between the
> CONSTANT and the GLOBAL VARIABLE ??
>
A constant is a value that never changes, whereas a variable can change
its value (which means that there cannot be something like a "constant
variable" or a "variable constant", similar to a "variable datum", which
is also an oxymoron).
A global variable is one that is available in any context (any script
and any function even when not explicitly declared in that one).
Examples: the constant M_PI has the value of pi. No matter what you do,
M_PI does not change its value. You can also use the function pi() to
have the value of M_PI returned.
You can use the PHP keyword global to make any variable to have global
scope. Some variables are global per definition and are called the
superglobals, such as $_SERVER or $_SESSION.
Hope that helps,
David
More information about the talk
mailing list