I know it's not really necessary to define all variables but i'd like to do so anyway. when i use var $myvar; i get a parse error. how else can i define a variable?
With PHP, you don't use the keyword "var" to declare a variable. All you need to do to initialize a variable is set it. Thus you could do something like:
$mystringvar = '';
$mynumericvar = 0;
PHP does have a syntax for defining constants, though (
Now the constant CONSTANT_NAME can be used anywhere in your code, inside or outside of functions. Constants have a truly global scope, and they can't "accidentally" have new values assigned to them. For this reason they are good for such things as passwords, directory paths, etc... things that you wouldn't want a querystring hacker to mess with. -------------------------------------------
"Now, this might cause some discomfort..."
(
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.