Log in

View Full Version : $bbuserinfo[usergroupid] vs. $bbuserinfo['usergroupid']


Darth Cow
07-27-2002, 12:55 AM
Is there a difference? My meager PHP knowledge would assume they are both the same :).

Velocd
07-27-2002, 01:37 AM
I have found both being used in PHP files, but only $bbuserinfo[usergroupid] being used within the templates. I believe they work almost the same, but don't quote me. :)

Admin
07-27-2002, 06:13 AM
You got some reading to do. :)
Why is $foo[bar] wrong? (http://php.fastmirror.com/manual/en/language.types.array.php#language.types.array.foo-bar)

Velocd: It is right in templates, because templates are evaluated as strings, and you can't use $foo['bar'] in strings (unless you surround it with { and }, i.e {$foo['bar']}).
Constants are also not parsed inside strings, so even if they make bar a constant (for the sole purpose of killing time), "$foo[bar]" will work just fine.

Darth Cow
07-28-2002, 07:50 PM
Hehe... thanks :).

I learned to do $foo["bar"] and use {foo["bar"]} within strings from my PHP book, but then I noticed that it's sometimes used with just $foo[bar] in the vbulletin source code. Well, now I know :p.

Admin
07-29-2002, 06:54 AM
vB3 should have $foo['bar'] instead of $foo[bar], except for templates.