Reputation: 31
Strange, i am using apache + php with windows. php processed mysql bit fields as number: it's work correct;
$b = $row['bit_field']
if ($b == 1) {
echo 'ok';
}
with centos and php 5.3.3 './configure' '--with-mysql' '--with-mcrypt' '--enable-mbstring' '--with-imap' '--with-kerberos' '--with-imap-ssl' '--with-libjpeg' '--with-libpng' '--with-gd'
i need
$b = $row['bit_field']
if (ord($b) == 1) {
echo 'ok';
}
What option changing it?
-- Thanx
Upvotes: 3
Views: 3653
Reputation: 31730
If the field you're dealing with is indeed a bit field, then surely you should be using the bit field operators to test what bits are set in the value?
if ($b & 0X1) { echo ('Least significant bit in byte set'); }
if ($b & 0X80) { echo ('Most significant bit in byte set'); }
if ($b & 0X80000000) { echo ('Most significant bit in 32 bit word set'); }
You can use these to check individual bits in a bit field regardless of the values of the other bits.
Upvotes: 5