For example, in PHP, how would I reverse the bits of the byte 11011111 to 11111011?
11011111
11111011
The straight forward approach is to perform 8 masks, 8 rotates, and 7 additions:
$blah = $blah & 128 >> 7 + $blah & 64 >> 5 + $blah & 32 >> 3 + $blah & 16 >> 1 + $blah & 8 << 1 + $blah & 4 << 3 + $blah & 2 << 5 + $blah & 1 << 7;