|
-
Aug 29th, 2008, 11:32 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Difference between $_Test[_Var1] V.S. $_Test_Var1
Hi,
What is difference between $_Test[_Var1] V.S. $_Test_Var1?
Ex.:
$_Test[_Var1]= ...
$_Test[_Var2]= ...
$_Test[_Var3]= ...
V.S.
$_Test_Var1= ...
$_Test_Var2= ...
$_Test_Var3= ...
Thanks for answer .
-
Aug 29th, 2008, 12:22 PM
#2
Re: Difference between $_Test[_Var1] V.S. $_Test_Var1
Apart from their names: $_Test[_Var1] is a variable that is an array with the index _Var1, as _VAR1 is not a string it should be declared prior as a constant. $_Test_Var1 is a variable rather than an array.
-
Aug 29th, 2008, 10:39 PM
#3
Re: Difference between $_Test[_Var1] V.S. $_Test_Var1
If _Var1 is not declared as a constant and strict mode is off then the interpreter will assume it means the string '_Var1' and generate a notice to this effect. If you have not already I strongly recommend enabling strict mode and using the full error reporting level (at least during development) in order to catch any ambiguous coding such as this.
Also, I would avoid using names that begin with an underscore since the underscore conventionally indicates a variable that is pre-populated by the interpreter.
Last edited by penagate; Aug 29th, 2008 at 10:43 PM.
-
Aug 30th, 2008, 10:44 AM
#4
Thread Starter
Addicted Member
Re: Difference between $_Test[_Var1] V.S. $_Test_Var1
Thanks both .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|