我怎样才能简化这个结构:
$properties = $rs->$domains[0];
$dn = $properties[0]->distinguishedname;
因为 PHP 在这种构造上给出了错误:
$dn = $rs->$domains[0][0]->distinguishedname
我怎样才能简化这个结构:
$properties = $rs->$domains[0];
$dn = $properties[0]->distinguishedname;
因为 PHP 在这种构造上给出了错误:
$dn = $rs->$domains[0][0]->distinguishedname
这应该有效,或者更确切地说,它们都不应该有效。
要使用运算符访问对象的成员,->
您不需要使用$
两次,据我所知,它应该抛出某种错误或警告。
$properties = $rs->$domains[0];
$dn = $properties[0]->distinguishedname;
应该:
$properties = $rs->domains[0];
$dn = $properties[0]->distinguishedname;
同样地:
$dn = $rs->$domains[0][0]->distinguishedname;
应该:
$dn = $rs->domains[0][0]->distinguishedname;
这是我在您的代码中看到的唯一问题。
只要快速查看它,似乎只要数据实际存在,您的代码就应该可以工作。也许您尝试从没有属性的域中获取专有名称?
php错误说明了什么?对您的数据结构执行 *var_dump* 以查看它实际上包含您期望的数据。