示例#1
0
 /**
  * Determines the endianness of the host platform and memoizes
  * the result to Avro::$endianness.
  *
  * Based on a similar check perfomed in http://pear.php.net/package/Math_BinaryUtils
  *
  * @throws AvroException if the endianness cannot be determined.
  */
 private static function set_endianness()
 {
     $packed = pack('d', 1);
     switch ($packed) {
         case "?ð":
             self::$endianness = self::BIG_ENDIAN;
             break;
         case "ð?":
             self::$endianness = self::LITTLE_ENDIAN;
             break;
         default:
             throw new AvroException(sprintf('Error determining platform endianness: %s', AvroDebug::hex_string($packed)));
     }
 }