Monday, November 25, 2019

Get Static Properties from a PHP Class

We will get all the static properties as an PHP Array

private function theme_default_value ($key) {
  $full_class_path = Constants::$my_namespace . 'MyClass';
  $class = new \ReflectionClass( $full_class_path );
  $default_value = $class->getStaticPropertyValue( $key );
  return $default_value;
}

No comments:

Post a Comment

css snippet for blogger code highlighting

code, .code {     display: block;     background: beige;     padding: 10px;     margin: 8px 15px; }