Wednesday, December 16, 2015

The output looks like JSON but it is not valid JSON - meet the PHP's serialize function

Check this string:


a:3:{s:6:"tokens";a:2:{s:5:"test1";i:1}}
 
If you have wondered how this type of string format is called, it's called the output of PHP's serialize() function! :)

This is an example of output from serialize() function. This output is generated by saving the fields of an object. The object can be re-generated from this string with unserialize() function.

More details:
http://php.net/manual/en/function.serialize.php

No comments:

Post a Comment

Ubuntu 12.04, 14.04, 16.04 - auto start an app or script before login

To run a command or application at startup, even before the user has logged in, you can use this file: /etc/rc.local The commands entered...