Why does unserialize in PHP keep returning false?

I just wrote the lightest script in the world, but still I can't get it to work, and it may seem weird.

I want to use jQuery to catch some values ​​of input fields and serialize them using jQuery serialize(). Then I send the serialized string to the server to unserialize it. Here, the output I get from serialization in jQuery is what I send to the server.

field1=value1&field2=value2&field3=value3

And here is the function

public function unserialize_input()
{
    $str = $this->input->post("user_values");
    $unserialized = unserialize($str);
    var_dump($unserialized);
}

Like I said, if I go "echo $ str;" I get "field1 = value1 & field2 = value2 & field3 = value3", so the string should be non-realizable. However, I always get the same error message, and var_dump($unserialized);always return bool (false).

, CodeIgniter, , PHP.

Severity: Notice
Message: unserialize() [<ahref='function.unserialize'>function.unserialize</a>]: Error at offset 0 of 41 bytes

bool(false) 

MAMP . - magic_quotes_gpc, , . ?

+3
3

PHP. parse_str.

 parse_str($str, $unserialized);
+8

PHP serialize unserialize / PHP/.

jQuery serialize POST, Ajax-. - ​​PHP ​​ PHP , , false.

+4

This will be a bit vague because I don't know jQuery very well, but maybe jQuery serializes strings, even slightly different from PHP? If so, this will result in an error message.

0
source

Source: https://habr.com/ru/post/1711722/


All Articles