12-28-2003, 03:17 AM
is it alright to use the $ to define a variable in ASP like in PHP? i know you don't have to but i think it would be easyer to read the code if you add a $ sign in front of the variables. so anyways, is there a problem with that?
12-28-2003, 03:30 AM
I get the following error, do you?
Microsoft VBScript compilation error '800a0408'
/testing/test1.asp, line 3
12-30-2003, 04:50 AM
You declare variables in ASP/VBScript using the "Dim" keyword, for "Dimension".
strFruit = "Apple"
Yeah, it's not common to other languages... but what do you want from Microsoft? That's just the way it is.
P.S. Regarding your statement "I know you don't have to", that's not always true.
If you want to be able to use a variable globally (i.e. something used outside of a subroutine or function that you want to use inside such constructs), you HAVE to dimension it in order for it to carry a value.
A good practice for making sure you DO declare such variables is using "Option Explicit" at the top of your VB scripts.
A colleague I work with often questions why I do that... if he only realized how many times I've helped him fix things (and/or fixed errors in his scripts for the same reason) because he DOESN'T use Option Explicit, he'd quit asking me that question!!!
01-06-2004, 02:57 PM
I think what he/she meant with "I know you don't have to" is "I know you don't have to (use the $ sign in a variable)"