如何在 PHP 中使用查询字符串传递对象或数组
How to pass Object or array with Query string in PHP
我正在学习 PHP 并想知道如何使用 php 传递带有查询字符串的数组或对象?我做了 google 但找不到关于它的好答案。
我在想什么?
http://www.example.com/abc?array('a','b','c')
http://www.example.com/abc?object("a":"a","b":"b")
我比较喜欢..你可以试试
<?php
$link = "http://www.example.com/abc?";
//try with object
// $a = new stdClass();
// $a->a = "a";
// $a->b = "b";
//try with array
$a = ["a","b","c"];
header("location:{$link}param=".json_encode($a));
www.example.com/abc
<?php
$data = json_decode($_GET["param"]);
var_dump($data);
我正在学习 PHP 并想知道如何使用 php 传递带有查询字符串的数组或对象?我做了 google 但找不到关于它的好答案。 我在想什么?
http://www.example.com/abc?array('a','b','c')
http://www.example.com/abc?object("a":"a","b":"b")
我比较喜欢..你可以试试
<?php
$link = "http://www.example.com/abc?";
//try with object
// $a = new stdClass();
// $a->a = "a";
// $a->b = "b";
//try with array
$a = ["a","b","c"];
header("location:{$link}param=".json_encode($a));
www.example.com/abc
<?php
$data = json_decode($_GET["param"]);
var_dump($data);