duangou1868 2017-02-17 18:08
浏览 32
已采纳

PHP访问StdClass在athor StdClass中[重复]

This question already has an answer here:

How to access to StdClass's element who is within an athor StdClass.

this is what var_dump return:

 stdClass Object
(
    [return] => stdClass Object
        (
            [barCode] => 530884HB|4320000007;502241VA|4320000008;
            [code] => 0
            [idAffiliate] => 0
            [idOrder] => 25
            [idProduct] => 320
            [message] => Résérvation effectué avec succés
            [quantity] => 2
        )

)

And I want to get the value of the [barCode]??

</div>
  • 写回答

1条回答 默认 最新

  • douka19950505 2017-02-17 18:12
    关注

    Since the property return is a public property, you could simply get the barCode like this:

    $object->return->barCode

    Example:

    $object = new StdClass();
    $object->return = new StdClass();
    $object->return->barCode = '530884HB|4320000007;502241VA|4320000008';
    

    var_dump of the object:

    object(stdClass)#1 (1) {
      ["return"]=>
      object(stdClass)#2 (1) {
        ["barCode"]=>
        string(39) "530884HB|4320000007;502241VA|4320000008"
      }
    }
    

    print_r of the object:

    stdClass Object
    (
        [return] => stdClass Object
            (
                [barCode] => 530884HB|4320000007;502241VA|4320000008
            )
    
    )
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 微信小程序跑脚本授权的问题
  • ¥100 房产抖音小程序苹果搜不到安卓可以付费悬赏
  • ¥15 STM32串口接收问题
  • ¥15 腾讯IOA系统怎么在文件夹里修改办公网络的连接
  • ¥15 filenotfounderror:文件是存在的,权限也给了,但还一直报错
  • ¥15 MATLAB和mosek的求解问题
  • ¥20 修改中兴光猫sn的时候提示失败
  • ¥15 java大作业爬取网页
  • ¥15 怎么获取欧易的btc永续合约和交割合约的5m级的历史数据用来回测套利策略?
  • ¥15 有没有办法利用libusb读取usb设备数据