I put an array serialized in MySQL, and then get it in PHP, sent in JSON format, the interface to accept this data, and then convert the JSON into an array, and finally found that the array product_list key to the corresponding serialized array can not be deserialized, What is this for?
- The product_list in a array is an array
- Serializing Product_list into a library
- PHP queries the database and converts the entire large array into JSON sent to the interface caller
4. The requested interface put the JSON into an array, after successfully converting to an array, the product_list keys of the arrays are found, the corresponding
The deserialization of the data conversion to an array failed
Reply content:
I put an array serialized in MySQL, and then get it in PHP, sent in JSON format, the interface to accept this data, and then convert the JSON into an array, and finally found that the array product_list key to the corresponding serialized array can not be deserialized, What is this for?
- The product_list in a array is an array
- Serializing Product_list into a library
- PHP queries the database and converts the entire large array into JSON sent to the interface caller
4. The requested interface put the JSON into an array, after successfully converting to an array, the product_list keys of the arrays are found, the corresponding
The deserialization of the data conversion to an array failed
It may be because of the Chinese encoding. PHP is dependent on byte length when deserializing.
Do not use PHP serialization to be stored in, turn into JSON, so much more versatile. Who can guarantee that this data is always read by PHP?
I have ever encountered a situation where the same string, the result of my local serialization, is not the same as the result of the serial number on the remote server. I didn't delve into it because it didn't affect my system. But I know there's a phenomenon that can happen:
Perhaps because of the PHP version of the problem, perhaps because of the problem of PHP extension, and perhaps because of coding and so on for some reason, in different server environments, the result of PHP serialization is unstable unreliable.