The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Why is $foo[bar] wrong?
I see this alot in hacks and the vb code in general, so I thought I'd quote the PHP manual:
Quote:
|
#2
|
|||
|
|||
its a handy way of replacing vars with their value within strings.
its quicker to go: echo ("sometext $foo[bar] some more text"); than it is to go: echo ("sometext ".$foo['bar']." some more text"); ...but yes it is possible this might cause problems in the future with backwards compatibility - fair point. |
#3
|
||||
|
||||
It's just lazy programming. vB3 has everything done properly, i.e.
$foo['bar']; $foo["$bar"]; |
#4
|
||||
|
||||
There is nothing wrong with using $foo[$bar] since $bar can never be a constant, and it's an expression. And in case you use a value from an array as an index for another array, using $post[$user['userid']] is better than $post["$user[userid]"] (since you can't do $post["$user['userid']"]).
|
#5
|
|||
|
|||
Firefly do you help programme vBulletin aswell?
|
#6
|
||||
|
||||
Well if $bar happens to be -1 than $foo[$bar] blows up if you are expecting -1 to be a string. $foo["$bar"] doesn't blow up.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|