Hide specific class fields from print_r or var_dump

前端 未结 6 1618
无人及你
无人及你 2021-01-02 01:22

Is it possible to hide a specific class fields from print_r ?



        
6条回答
  •  暖寄归人
    2021-01-02 01:41

    Yes, but only internally. It's just a matter of not exposing the relevant property in the hash table returned by the get_properties handler.

    You can also hide the property behind a __get handler, but you still have to store the data somewhere and __get has a performance (and clarity) penalty.

提交回复
热议问题