在 PHP 中访问对象成员 [英] Accessing object members in PHP

查看:69
本文介绍了在 PHP 中访问对象成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 PHP 调用 WCF 服务,它返回给我这个东西:(我调用的服务返回一个 C# 结构)

I'm calling a WCF service in PHP which returns me this thing: (The service I'm calling returns a C# struct)

object(stdClass)#70 (1) {
  ["SiteInterop_CreateContactAndOpportunityResult"]=>
    object(stdClass)#149 (5) {
      ["result"]=>
        bool(true)
      ["strAccountExec"]=>
        NULL
      ["strAccountId"]=>
        string(36) "bd346671-88ca-4966-971a-9dd499c7a689"
      ["strContactId"]=>
        string(36) "06a8808d-ed66-42f9-a821-00358213bb94"
      ["strOpportunityId"]=>
        string(36) "d4845fd0-18fb-4a40-8424-904866cb471e"
    }
}

问题是,我如何访问这些值?这些值是真正的布尔值和三个 guid.

Question is, how do I access the values? Those values are the true boolean and three guids.

推荐答案

获取result

$var->SiteInterop_CreateContactAndOpportunityResult->result;

获取guids

$var->SiteInterop_CreateContactAndOpportunityResult->strAccountId
$var->SiteInterop_CreateContactAndOpportunityResult->strContactId
$var->SiteInterop_CreateContactAndOpportunityResult->strOpportunityId

这篇关于在 PHP 中访问对象成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆