With class type
class MyClass { static var1 = "a"; static var2 = "b"; }
... I would like to get static members and their values at runtime; sort of
Array( "var1" => "a", "var2" => "b" )
Is there a way to do this in PHP?
You can use ReflectionClass::getStaticProperties()to do this:
ReflectionClass::getStaticProperties()
$class = new ReflectionClass('MyClass'); $arr = $class->getStaticProperties();
Array ( [var1] => a [var2] => b )
http://www.php.net/manual/en/reflectionclass.getstaticproperties.php - try
Getting information about classes and class properties, such as all static methods, is called reflection.
Source: https://habr.com/ru/post/1667580/More articles:how to make native packer react ignore specific directories - react-nativeCSS: the last child of a parent - htmlThere is no space left when moving the image on the device - dockerPreact and Webpack for production - reactjsprint_r shows private var. What for? - privateЕсть ли веская причина по-прежнему писать ANSI C (C89/90) совместимый код? - cJava Enums provide uniqueness for the field - javaNested with hiearchy expression - vbaKeyPairGenerator.generateKeyPair () in Android 7.1.1 - androidAfter connecting my aurelia application, I get: No error PLATFORM.Loader - jspmAll Articles