This little function returns true if a data string was made by igbinary_serialize() and can be passed to igbinary_unseriaize().
function is_igbinary($data) {
return is_string($data) && '00000002' === bin2hex(substr($data, 0, 4));
}
It doesn't validate the contents of the data string, or ensure it is safe to decode if it came from an untrusted source. But it is handy when trying to avoid unserializing data that wasn't serialized.