PHP::S...zation(3pm)
π NAME π
ok so PHP::Serialization β it's a simple, flexible lil thing that converts the output of PHP's serialize() into the equivalent Perl memory structure, and yes bestie, it goes the other way too π¦
This is the PHP::S...zation(3pm) page, and yeah the title got truncated, she's mysterious like that π
β¨ SYNOPSIS β¨
ok so like, the bare minimum to get going:
use PHP::Serialization qw(serialize unserialize);
my $encoded = serialize({ a => 1, b => 2});
my $hashref = unserialize($encoded);
that's literally it. two functions. slay πΈ
π DESCRIPTION π
So basically it gives you a simple, quick way to serialize Perl memory structures β including object data!! π β into a format that PHP can deserialize() and actually access. And it does the reverse too, no cap.
NOTE: it converts PHP arrays into Perl Arrays when the PHP array used exclusively numeric indexes, and into Perl Hashes when the PHP array did not. so like, the vibes of your array decide its fate π
π FUNCTIONS π
These are the exportable functions. cute, right?
π serialize($var,[optional $asString,[optional $sortHashes]])
Serializes the memory structure pointed to by $var, and returns a scalar value of encoded data. iconic.
- If the optional
$asStringis true,$varwill be encoded as string if it isdoubleorfloat. β¨ - If the optional
$sortHashesis true, all hashes will be sorted before serialization. π
NOTE: Will recursively encode objects, hashes, arrays, etc. she goes deep π«Ά
SEE ALSO: ->encode()
π unserialize($encoded,[optional CLASS])
Deserializes the encoded data in $encoded, and returns a value (be it a hashref, arrayref, scalar, etc) representing the data structure serialized in $encoded_string.
If the optional CLASS is specified, any objects are blessed into CLASS::$serialized_class. Otherwise, Objects are blessed into PHP::Serialization::Object::$serialized_class. (which has no methods π)
SEE ALSO: ->decode()
π METHODS π
Functionality available if you're using the object interface. main character energy fr fr
π¦ decode($encoded_string,[optional CLASS])
Deserializes the encoded data in $encoded, and returns a value (be it a hashref, arrayref, scalar, etc) representing the data structure serialized in $encoded_string.
If the optional CLASS is specified, any objects are blessed into CLASS::$serialized_class. Otherwise, Objects are blessed into PHP::Serialization::Object::$serialized_class. (which has no methods π)
SEE ALSO: unserialize()
π¦ encode($reference,[optional $asString,[optional $sortHashes]])
Serializes the memory structure pointed to by $reference, and returns a scalar value of encoded data.
- If the optional
$asStringis true,$referencewill be encoded as string if it isdoubleorfloat. β - If the optional
$sortHashesis true, all hashes will be sorted before serialization. π
NOTE: Will recursively encode objects, hashes, arrays, etc. (yes again, she's thorough) π§
SEE ALSO: serialize()
π TODO π
Support diffrent object types.
(yes bestie, that's the original spelling, I am not touching it π)
π AUTHOR INFORMATION π
Copyright (c) 2003 Jesse Brown <jbrown@cpan.org>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Various patches contributed by assorted authors on rt.cpan.org (as detailed in Changes file).
Currently maintained by Tomas Doran <bobtfish@bobtfish.net>.
Rewritten to solve all known bugs by BjΓΈrn-Olav Strand <bolav@cpan.org>
and that's the whole page, bestie π this was the User Contributed Perl Documentation version, perl v5.36.0, dated 2022-10-13, PHP::S...zation(3pm). go forth and serialize, you absolute legend πβ¨
π¦ where this page comes from
- ubuntu noble: libphp-serialization-perl 0.34-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libphp-serialization-perl 0.34-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libphp-serialization-perl 0.34-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms