Check variable is public php

后端 未结 3 1392
借酒劲吻你
借酒劲吻你 2021-01-29 10:49

I want to check if a local variable in a class is public or private. The reason is to create a function like this:

function ToArray() {
  $arr = array();
  forea         


        
3条回答
  •  情话喂你
    2021-01-29 11:14

    Make sure to follow some naming convention with your private variables (like i prepend them with _)

    Then just return those variables that do not have _ in the beginning of their key.

提交回复
热议问题