将json对象作为url参数传递

<?php  
  $jsonData = array(
    "comments" => "Fresh food",
    "container" => false,
    "cookedTime" => 2,
    "description" => "biryani",
    "refridgeration" => true,
    "serves" => 2,
    "veg" => true
);

json_encode($jsonData);
header("Location:Post.php?json=$jsonData");
?>

This is my php page which contains json object. I am passing this json object into another page Post.php.

<?php
$jsonData = $_GET['json'];
json_decode($jsonData, TRUE);
echo var_dump($jsonData);
?>

when I did a dump the result is C:\wamp\www\Hack\Post.php:16:string 'Array' (length=5). It is printing "Array" instead of the json object. What do I do?

查看全部
doushao1948
doushao1948
2016/10/22 13:38
  • json
  • php
  • url
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

3个回复