In PHP what does it mean by a function being binary-safe?

It means the function will work correctly when you pass it arbitrary binary data (i.e. strings containing non-ASCII bytes and/or null bytes).

For example, a non-binary-safe function might be based on a C function which expects null-terminated strings, so if the string contains a null character, the function would ignore anything after it.

This is relevant because PHP does not cleanly separate string and binary data.

Leave a Comment