从对象获取字符串

时间:2013-05-28 18:33:33

标签: php string object

如何从PHP中获取此对象的电子邮件变量?

$data = $_POST["data"];

$data的内容:

Object {email: "peter.m@gmail.com"} 

2 个答案:

答案 0 :(得分:2)

也许这是一个json字符串? 尝试:

$data = json_decode($data);
$email = $data->email;

答案 1 :(得分:0)

这应该有效"

$email_string = $data->email;  //should work

//    or

$email_string = $data['email'];   //might also work