Q. 1: What is Serialization in Laravel?
It's similar to turning an object into JSON, but with the advantage that PHP will remember the native data type of each serialized item (string, array, integer, float, boolean).
PHP and Javascript can only communicate via strings. You can pass the string "foo" very easily to Javascript. You can pass the number 1 very easily to Javascript. You can pass the boolean values true and false easily to Javascript. But how do you pass this array to Javascript?
The answer is serialization. In case of PHP/Javascript, JSON is actually the better serialization format:
**echo json_encode($array)
Top comments (1)
Hi there, we encourage authors to share their entire posts here on DEV, rather than mostly pointing to an external link. Doing so helps ensure that readers don’t have to jump around to too many different pages, and it helps focus the conversation right here in the comments section.
If you choose to do so, you also have the option to add a canonical URL directly to your post.