This is why I had this problem and how I developed it:
I stored an array in my input like this:
value="<?php echo htmlspecialchars(serialize(array($a, $b))); ?>"
Here I had to use htmlspecialchars() due to possible parsing errors.
Then, when I tried to perform non-serialization, he gave me this error Error at offset X of Y bytes in ... I printed a non-serialized string on the screen, I realized that the html equivalents of some characters cause an error.
To be more clear, the double quote mark of %22 html codes caused this error. So I replaced them with quotes and worked.
unserialize(str_replace('%22', '"', $_POST['serialized']));
So itβs better to check if there are any html codes in the serialized string and replace them with the original characters.
kubilay
source share