Пример #1
0
 /**
  * Returns a string with the byte representation of a IEEE 754 double in
  * 64 bit precision. Works fine between PHP clients and servers but it uses
  * a machine dependent byte packing representation (pack format "d").
  *
  * <B>WARNING:</B> Due to incompatible double formats among different machines, this function
  * is not guaranteed to return the number with extreme accuracy, specially with periodic fractions
  * such as 1.3333... Take this in account.<BR>
  *  
  * @param double number number to be transformed 
  * @return string byte representation
  * @access public 
  **/
 function getFloatBytes($number)
 {
     $bin = Hessian_ByteUtils::orderedByteString(pack("d", $number));
     // Machine-dependent size
     // check is deactivated
     /*if(strlen($bin) != 8) {
     			echo "Sorry, your machine uses an unsupported double-precision floating point size.";
     		}*/
     return $bin;
 }
Пример #2
0
 /**
  * Main parsing function that reads the head code from the stream and returns the appropriate PHP value
  * Thanks to Radu-Adrian Popescu for his patch to 'long' and 'date' deserializing.
  *  
  * @param string code Hessian object code 
  * @return mixed parsed value
  **/
 function &parseObject($code = '')
 {
     if ($code == '') {
         $code = $this->read(1);
     }
     $this->lastCode = $code;
     switch ($code) {
         case 'N':
             return null;
         case 'F':
             return false;
         case 'T':
             return true;
         case 'I':
             $data = unpack('N', $this->read(4));
             return $data[1];
         case 'L':
             return $this->readLong(true);
         case 'd':
             $ts = $this->readLong();
             return $this->dateProvider->readDate($ts);
         case 'D':
             /*
             				2005-09-14:
             				Changed due to the "Fatal error: Only variables can be passed by reference" bug in PHP 5.1 
             old code:
             
             				$bytes = ByteUtils::orderedByteString($this->read(8));
             				$value = each(unpack("d",$bytes));
             				return $value[1];
             */
             $bytes = Hessian_ByteUtils::orderedByteString($this->read(8));
             $val = unpack("d", $bytes);
             $value = array_pop($val);
             return $value;
         case 'B':
         case 'b':
             return $this->readBinary();
         case 'S':
         case 's':
         case 'X':
         case 'x':
             return $this->readString();
         case 'M':
             return $this->parseMap();
         case 'V':
             return $this->parseList();
         case 'R':
             $refStruct = unpack('N', $this->read(4));
             $numRef = $refStruct[1];
             if (isset($this->refs[$numRef])) {
                 return $this->refs[$numRef];
             } else {
                 return new Hessian_HessianError("Unresolved referenced object number {$numRef}", HESSIAN_PARSER_ERROR, 0, $this->stream);
             }
             break;
         case 'z':
             $this->end = true;
             return;
         case 'f':
             return $this->parseFault();
         default:
             return new Hessian_HessianError("Unrecognized response type code '{$code}' or not implemented", HESSIAN_PARSER_ERROR, 0, $this->stream);
     }
 }