zoukankan      html  css  js  c++  java
  • php protected 类型如何获取

    感谢

    https://blog.csdn.net/m0_38092942/article/details/81354184

    比如对象如下

    object(AppUser)#265 (28) {
      ["attributes":protected]=>
      array(47) {
        ["d"]=>
        int(0)
        ["t"]=>
        int(0)
        ["enable"]=>
        int(1)
      }
      ["original":protected]=>
      array(47) {
        ["d"]=>
        int(0)
        ["t"]=>
        int(0)
        ["enable"]=>
        int(1)
      }
      ["rememberTokenName":protected]=>
      string(14) "remember_token"
      ["accessToken":protected]=>     //此为要获取的数据
      object(LaravelPassportToken)#267 (26) {
        ["attributes":protected]=>
        array(9) {
          ["id"]=>
          string(80) "b79367e0ae9e601714cea9c4dbe387a48f82e4b6a01ac53c71ed4c39a86db5991e30bab49b9c29cd"
          ["user_id"]=>
          int(146)
          ["client_id"]=>
          int(4)
          ["name"]=>
          NULL
          ["scopes"]=>
          string(2) "[]"
          ["revoked"]=>
          int(0)
          ["created_at"]=>
          string(19) "2018-08-02 10:01:19"
          ["updated_at"]=>
          string(19) "2018-08-02 10:01:19"
          ["expires_at"]=>
          string(19) "2018-08-17 10:01:19"
        }
        ["original":protected]=>
        array(9) {
          ["id"]=>
          string(80) "b79367e0ae9e601714cea9c4dbe387a48f82e4b6a01ac53c71ed4c39a86db5991e30bab49b9c29cd"
          ["user_id"]=>
          int(146)
          ["client_id"]=>
          int(4)
          ["name"]=>
          NULL
          ["scopes"]=>
          string(2) "[]"
          ["revoked"]=>
          int(0)
          ["created_at"]=>
          string(19) "2018-08-02 10:01:19"
          ["updated_at"]=>
          string(19) "2018-08-02 10:01:19"
          ["expires_at"]=>
          string(19) "2018-08-17 10:01:19"
        }
      }
    }

    转化为数据

    $data = (array)$object

    获取数据(重点在这里)

    $data["*accessToken"]->id
  • 相关阅读:
    hihocoder_offer收割编程练习赛53_2hiho字符串3
    hihocoder_offer收割编程练习赛53_1继承顺位
    网易招聘笔试题--牛牛的背包问题
    EJB3.0快速入门
    MyEclipse的常用快捷操作----非常实用!!!
    Spring2.5零散笔记
    Hibernate零散笔记
    一个问题引发的OOA&OOD讨论.
    如何使用JUnit进行单元测试
    Log4j自学笔记
  • 原文地址:https://www.cnblogs.com/zonglonglong/p/10114222.html
Copyright © 2011-2022 走看看