是否可以从url链接中提取对象值?

时间:2017-01-04 07:49:11

标签: php

我想使用PHP提取对象值而不是url参数。 这是我的链接http://reussis.com/match-betting/admin2/edit_withdrawal_request.php?id=[object%20Object]

php code

print_r($_GET['id']);

当我打印时我没有得到任何值为什么? 这是愚蠢的问题,请忽略。谢谢!

2 个答案:

答案 0 :(得分:1)

您无法直接通过HTTP传递JavaScript对象,因为HTTP不是JavaScript。

在您的对象上按JSON.stringify()序列化,然后将其作为encodeURIComponent()网址字符串传递。

例如:

let myObject = {'javascript': 1, 'isNumberOne': true};
// Serialises the object into a string, then urlencode it
encodeURIComponent(JSON.stringify(myObject)); // "%7B%22javascript%22%3A1%2C%22isNumberOne%22%3Atrue%7D"

答案 1 :(得分:-1)

使用POST方法代替GET。 GET方法是一种旧式,很容易出现黑客攻击。立即尝试重建您的计划!祝你好运。