| 1 |
NAME |
| 2 |
PHP::Serialization - simple flexible means of converting the output of |
| 3 |
PHP's serialize() into the equivalent Perl memory structure, and vice |
| 4 |
versa. |
| 5 |
|
| 6 |
SYNOPSIS |
| 7 |
use PHP::Serialization qw(serialize unserialize); |
| 8 |
my $encoded = serialize({ a => 1, b => 2}); |
| 9 |
my $hashref = unserialize($encoded); |
| 10 |
|
| 11 |
DESCRIPTION |
| 12 |
Provides a simple, quick means of serializing perl memory structures |
| 13 |
(including object data!) into a format that PHP can deserialize() and |
| 14 |
access, and vice versa. |
| 15 |
|
| 16 |
NOTE: Converts PHP arrays into Perl Arrays when the PHP array used |
| 17 |
exclusively numeric indexes, and into Perl Hashes then the PHP array did |
| 18 |
not. |
| 19 |
|
| 20 |
FUNCTIONS |
| 21 |
Exportable functions.. |
| 22 |
|
| 23 |
serialize($var,[optional $asString,[optional $sortHashes]]) |
| 24 |
Serializes the memory structure pointed to by $var, and returns a scalar |
| 25 |
value of encoded data. |
| 26 |
|
| 27 |
If the optional $asString is true, $var will be encoded as string if it |
| 28 |
is double or float. |
| 29 |
|
| 30 |
If the optional $sortHashes is true, all hashes will be sorted before |
| 31 |
serialization. |
| 32 |
|
| 33 |
NOTE: Will recursively encode objects, hashes, arrays, etc. |
| 34 |
|
| 35 |
SEE ALSO: ->encode() |
| 36 |
|
| 37 |
unserialize($encoded,[optional CLASS]) |
| 38 |
Deserializes the encoded data in $encoded, and returns a value (be it a |
| 39 |
hashref, arrayref, scalar, etc) representing the data structure |
| 40 |
serialized in $encoded_string. |
| 41 |
|
| 42 |
If the optional CLASS is specified, any objects are blessed into |
| 43 |
CLASS::$serialized_class. Otherwise, O bjects are blessed into |
| 44 |
PHP::Serialization::Object::$serialized_class. (which has no methods) |
| 45 |
|
| 46 |
SEE ALSO: ->decode() |
| 47 |
|
| 48 |
METHODS |
| 49 |
Functionality available if using the object interface.. |
| 50 |
|
| 51 |
decode($encoded_string,[optional CLASS]) |
| 52 |
Deserializes the encoded data in $encoded, and returns a value (be it a |
| 53 |
hashref, arrayref, scalar, etc) representing the data structure |
| 54 |
serialized in $encoded_string. |
| 55 |
|
| 56 |
If the optional CLASS is specified, any objects are blessed into |
| 57 |
CLASS::$serialized_class. Otherwise, Objects are blessed into |
| 58 |
PHP::Serialization::Object::$serialized_class. (which has no methods) |
| 59 |
|
| 60 |
SEE ALSO: unserialize() |
| 61 |
|
| 62 |
encode($reference,[optional $asString,[optional $sortHashes]]) |
| 63 |
Serializes the memory structure pointed to by $reference, and returns a |
| 64 |
scalar value of encoded data. |
| 65 |
|
| 66 |
If the optional $asString is true, $reference will be encoded as string |
| 67 |
if it is double or float. |
| 68 |
|
| 69 |
If the optional $sortHashes is true, all hashes will be sorted before |
| 70 |
serialization. |
| 71 |
|
| 72 |
NOTE: Will recursively encode objects, hashes, arrays, etc. |
| 73 |
|
| 74 |
SEE ALSO: serialize() |
| 75 |
|
| 76 |
TODO |
| 77 |
Support diffrent object types |
| 78 |
|
| 79 |
AUTHOR INFORMATION |
| 80 |
Copyright (c) 2003 Jesse Brown <[email protected]>. All rights reserved. |
| 81 |
This program is free software; you can redistribute it and/or modify it |
| 82 |
under the same terms as Perl itself. |
| 83 |
|
| 84 |
Various patches contributed by assorted authors on rt.cpan.org (as |
| 85 |
detailed in Changes file). |
| 86 |
|
| 87 |
Currently maintained by Tomas Doran <[email protected]>. |
| 88 |
|
| 89 |
Rewritten to solve all known bugs by Bjørn-Olav Strand <[email protected]> |
| 90 |
|