Re: Which array declaration is better?
- From: "ZeldorBlat" <zeldorblat@xxxxxxxxx>
- Date: 31 May 2006 11:25:16 -0700
howachen@xxxxxxxxx wrote:
$t["test"] = "1";
$t[test] = "1";
They are the same, so which style is better and recommended?
Thanks.
Howa
The first one is better, primarily because the second one is not valid
syntax (although, depending on how PHP is configured it might not
complain).
"test" is the string containing the characters t, e, s, and t in that
order. test would refer to a constant (i.e. define('test', 1);). But
if there is no constant called test, PHP will throw the following
notice:
PHP Notice: Use of undefined constant test - assumed 'test'
and he just interprets it as the string "test". But just because you
can't see the error doesn't mean it isn't there :)
.
- References:
- Which array declaration is better?
- From: howachen
- Which array declaration is better?
- Prev by Date: Re: Image resize problems
- Next by Date: Re: Image resize problems
- Previous by thread: Which array declaration is better?
- Next by thread: PHP on IIS
- Index(es):
Relevant Pages
|