Horde_Serialize::serialize PHP Метод

serialize() публичный статический Метод

See the list of constants at the top of the file for the serializing techniques that can be used.
public static serialize ( mixed $data, mixed $mode = [self::BASIC], mixed $params = null ) : string
$data mixed The data to be serialized.
$mode mixed The mode of serialization. Can be either a single mode or array of modes. If array, will be serialized in the order provided.
$params mixed Any additional parameters the serialization method requires.
Результат string The serialized data.
    public static function serialize($data, $mode = array(self::BASIC), $params = null)
    {
        if (!is_array($mode)) {
            $mode = array($mode);
        }
        /* Parse through the list of serializing modes. */
        foreach ($mode as $val) {
            /* Check to make sure the mode is supported. */
            if (!self::hasCapability($val)) {
                throw new Horde_Serialize_Exception('Unsupported serialization type');
            }
            $data = self::_serialize($data, $val, $params);
        }
        return $data;
    }

Usage Example

Пример #1
0
 /**
  * Returns a serialized value, if necessary.
  *
  * @param mixed  The original value.
  *
  * @return string  The JSON encoded value if not already a string.
  */
 protected function _serializeAttribute($value)
 {
     if (!is_string($value)) {
         return Horde_Serialize::serialize($value, Horde_Serialize::JSON);
     }
     return $value;
 }
All Usage Examples Of Horde_Serialize::serialize