Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a Serialized PHP Object be formatted for easy readability?

PHP's Serializer produces a byte array which can be displayed as a single-line string via var_dump(). The format of this string is very difficult to read, especially for scenarios such as objects stored in a database.

For the sake of reading these values is it possible to convert these to an indented, formatted readable string? Or is the only option to retrieve them in PHP, unserialize() then, and then do something such as var_dump()?

like image 459
STW Avatar asked Oct 27 '25 15:10

STW


1 Answers

Here is a great 1 liner:

<?php echo "<pre>" . print_r(unserialize($yourvar), 1) . "</pre>"; ?>
like image 171
thexande Avatar answered Oct 30 '25 05:10

thexande



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!