vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   What does this symbol do? (https://vborg.vbsupport.ru/showthread.php?t=296738)

vBNinja 03-31-2013 11:33 PM

What does this symbol do?
 
PHP Code:

if ($vbulletin->userinfo['userid'] > AND ($vbulletin->userinfo['permissions']['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['custom_perm'])) 

I understand all of it but the "&" symbol in the middle. Im not sure if it's supposed to be "&&" or if it's trying to use references. But there's no equal sign so it can't be a reference. Does anyone know what it's supposed to be?

Thanks

kh99 03-31-2013 11:51 PM

It's the bitwise AND operator: http://php.net/manual/en/language.operators.bitwise.php. $vbulletin->userinfo['permissions']['forumpermissions'] is a number which, when you look at it as a binary value, each bit is the state of one forum permission for that user. $vbulletin->bf_ugp_forumpermissions['custom_perm'] is a "mask" value with only one bit set, the bit corresponding to the "custom_perm" permission (whatever that is). So if you "bitwise AND" those two values, the result will be either 0 or non-zero, depending on whether or not the user has that permission.

Probably that's either too much or not enough of an explanation. If it's not enough, this might help: http://en.wikipedia.org/wiki/Bitmask

vBNinja 04-01-2013 02:07 PM

Ahh it's pretty confusing but i think i got an idea of what it does, thanks!

nhawk 04-01-2013 04:31 PM

Just to confuse you a little more :D ...

A double ampersand "&&" is the same as AND in that code. So it could also appear as this..

PHP Code:

if ($vbulletin->userinfo['userid'] > && ($vbulletin->userinfo['permissions']['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['custom_perm'])) 


vBNinja 04-01-2013 05:00 PM

Quote:

Originally Posted by nhawk (Post 2413661)
Just to confuse you a little more :D ...

A double ampersand "&&" is the same as AND in that code. So it could also appear as this..

PHP Code:

if ($vbulletin->userinfo['userid'] > && ($vbulletin->userinfo['permissions']['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['custom_perm'])) 


Yea i know that "&&" and "AND" are the same thing :P


All times are GMT. The time now is 10:23 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01482 seconds
  • Memory Usage 1,729KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete