Log in

View Full Version : Global.php?


colicab-d
05-13-2003, 08:15 PM
Hi i put this code into global.php in an attempt to get some user specific graphics in my postbits.



switch ($bbuserinfo[usergroupid])
{

case 6 : $stbg="http://www.artorg.co.uk/cupboards/admin.gif"; break ;

case 8 : $stbg="http://www.artorg.co.uk/cupboards/contrib.gif"; break ;

case 5 : $stbg="http://www.artorg.co.uk/cupboards/staff.gif"; break ;

}



i tried just putting $stbg in the postbit template but to no luck?

how woul di get it to output the pictures in the postbit?

soz if this is a newb question im just not to sure about the workings of eval and stuf in vbulletin.

Any help is v.much appreciated :D

rake
05-13-2003, 08:29 PM
Put it in functions.php, getpostbit function. And use $post[usergroupid].

filburt1
05-13-2003, 08:38 PM
Actually use $post['usergroupid']. The other way is deprecated.

colicab-d
05-13-2003, 08:51 PM
thnx guys will do ;)

Boofo
05-13-2003, 09:26 PM
Today at 04:38 PM filburt1 said this in Post #3 (https://vborg.vbsupport.ru/showthread.php?postid=394707#post394707)
Actually use $post['usergroupid']. The other way is deprecated.

What the hell does "deprecated" mean? Talk english, filburt. Geesh! ;)

filburt1
05-13-2003, 09:35 PM
You shouldn't do it anymore :p

Search around at php.net for the explanation but the short story is that you're implying that usergroupid is a constant when it's really a literal.

Boofo
05-13-2003, 09:46 PM
Shouldn't do what anymore? ;)

Won't it work either way, though?

filburt1
05-13-2003, 10:24 PM
It'll work either way but it's extremely bad programming practice to rely on deprecated methods.

rake
05-14-2003, 08:01 PM
Array do's and don'ts
Why is $foo[bar] wrong?
You should always use quotes around an associative array index. For example, use $foo['bar'] and not $foo[bar]. But why is $foo[bar] wrong? You might have seen the following syntax in old scripts:


<?php
$foo[bar] = 'enemy';
echo $foo[bar];
// etc
?>



This is wrong, but it works. Then, why is it wrong? The reason is that this code has an undefined constant (bar) rather than a string ('bar' - notice the quotes), and PHP may in future define constants which, unfortunately for your code, have the same name. It works, because the undefined constant gets converted to a string of the same name automatically for backward compatibility reasons.