我试图打印出sessionkey的值并分配给变量,但我对如何在php中执行此操作感到困惑。
stdClass Object
(
[timeout] => 1800
[lastname] => cloud
[registered] => false
[username] => admin
[firstname] => admin
[domainid] => d323388a-ab41-11e4-91c4-464e571bcea9
[userid] => ff5705c6-ab41-11e4-91c4-464e571bcea9
[type] => 1
[sessionkey] => DPguBrSBFB7hcdNZAgAyMJIPm4c=
[account] => admin
)
输出var_dump
object(stdClass)#5 (10) { ["timeout"]=> string(4) "1800" ["lastname"]=> string(5) "cloud" ["registered"]=> string(5) "false" ["username"]=> string(5) "admin" ["firstname"]=> string(5) "admin" ["domainid"]=> string(36) "d323388a-ab41-11e4-91c4-464e571bcea9" ["userid"]=> string(36) "ff5705c6-ab41-11e4-91c4-464e571bcea9" ["type"]=> string(1) "1" ["sessionkey"]=> string(28) "vzaQz+uVdL/NQQE7eRSimP6FIf4=" ["account"]=> string(5) "admin" }
这是我尝试过的,但它不起作用。
foreach ($vms as $key => $obj) {
foreach (get_object_vars($obj) as $name => $value) {
echo "Object mapped to $key has property $name => $value";
}
}
但我会在日志中看到这一点。
PHP Notice: Trying to get property of non-object in
非常感谢您的帮助。