且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么是正确的方法来检查是否在php中打开了位字段

更新时间:2023-11-25 11:18:46

使用

if( $bit & (1 << $n) ) {
  // do something
}

其中$n是第 n 位,以得到减1 (例如,$n=0是获得最低有效位)

Where $n is the n-th bit to get minus one (for instance, $n=0 to get the least significant bit)