In a post to the SitePoint PHP site editor Bruno Skvorc wonders if bitwise operators are still relevant in modern PHP development.
Many of you probably scratched your heads reading this title. “Bitwhat?”In this article, we’ll look at what bitwise operators are, and whether or not their use is still relevant in this modern age of computing.
He starts off by illustrating a common use case for the bitwise operators in evaluating user permissions. He first proposes doing things on the database side, creating tables for double or single joins that could get us the information we need. He also shows an approach for what he calls a "column stampede": adding a new column to the user table when a new permission is needed. Instead he proposes the bitwise option, first explaining how values are stored and then showing how with a single value, you could potentially store all of a user's permissions in one field. Next he shows how to perform the select to determine of a user has a set of permissions and how to store them when making an insert/update.