mardi 16 juillet 2019

How to get the const/ static properties of a PHP class

I am developing a PHP application. Now, I am trying to loop through all the static/ const properties of a PHP class maybe through reflection.

I have a class like this

class MyClass
{
   const MY_CONST = "my_const";
   public static $MY_STATIC_PROP = "my_static_prop";
}

What I want to do is that I want to loop through all the properties of a class and check if the name of the property is equal to something.

if ($property_name == "something") {
    //do something
}

How can I do that in PHP?





Aucun commentaire:

Enregistrer un commentaire