8
उदाहरण वर्ग की एक सरणी प्राप्त करें?वर्ग स्थिर सदस्य चर
उदाहरण वर्ग की एक सरणी प्राप्त करें?वर्ग स्थिर सदस्य चर
हाँ है:
Reflection का उपयोग करना, और getStaticProperties() विधि
class Example{
public static $ONE = [1,'one'];
public static $TWO = [2,'two'];
public static $THREE = [3,'three'];
public static function test(){
$reflection = new ReflectionClass(get_class());
return $reflection->getStaticProperties();
}
}
var_dump(Example::test());