Result of the strange serialize

1

I made a serialization of an object in .php whose result is very different from the common one:

  

example.com/script.php?name=joao&same=silva&endereco=rua+dos+bobos+zero+amp&cpf=11111111111 ')

This is the result:

  

example.com.php? query = O: 8: "Query": 4: {s: 10: "resultType"; s: 8: "products"; s: 6: "search"; s: 12: "n": s: 9: "records"; N;}

Code:

$string = serialize($consulta);
$url = 'Location:'.'exibir.php?consulta='.$string;
header($url);

What's inside the object:

Consulta Object ( [resultType] => produtos [search] => lapis caneta [inicio] => [registros] => )
    
asked by anonymous 23.01.2015 / 21:33

1 answer

2

It seems to me that you are confusing the function of PHP with that of jQuery. In PHP, the function serialize serves to serialize an object so that it can be stored, not used in a query string of a HTTP GET request.

For the purpose you need, use http_build_query , which serializes the public properties of an object (also works with arrays).

    
23.01.2015 / 21:59