12
stdClass Object
(
[ModuleAccountInfo] => Array
    (
        [0] => stdClass Object
            (
                [ServerName] => EAST
                [HostingModule] => ActiveDirectory
                [ActiveDirectorySiteName] => EAST
                [AccountIdentity] => OU=ndla,OU=Hosting,DC=east,DC=domain,DC=local
                [Groups] => 2
                [Users] => 15
            )

        [1] => stdClass Object
            (
                [ServerName] => EAST.net
                [HostingModule] => hange
                [DiskQuota] => 375000
                [DiskQuotaAdditional] => 0
                [DateQuotaExceeded] => 0001-01-01T00:00:00
                [DiskSpace] => 58567
                [MailboxesDiskSpace] => 59973051
                [PublicFoldersDiskSpace] => 0
                [MessageArchivingDiskSpace] => 0
                [Contacts] => 8
                [Mailboxes] => 15

如何访问 ServerName 属性?该对象保存在 $modules 变量中。上面是 $modules 的 print_r。

4

1 回答 1

13

因为该ModuleAccountInfo属性是一个数组,所以您要么需要使用特定的索引

echo $modules->ModuleAccountInfo[0]->ServerName;

或循环

foreach ($modules->ModuleAccountInfo as $moduleAccountInfo) {
    echo $moduleAccountInfo->ServerName;
}
于 2013-10-10T00:07:22.893 回答