I'm learning PHP and in my book the author uses "reflection" to get the constants of an entity class(User) to do a bit-wise operation and compare them against data stored in database about each user to realize the level of access and privileges of each of them.
Now, the problem is, in the introduction section, as soon as this problem was posed by the author, I thought to myself I would pass an instance of the User entity class to this class(it's called "Register" and it is a controller) and then I would be able to use those constants that are defined in it. But then he solved this problem using "reflection". I understand how it works but I don't understand how one reaches this conclusion to use "reflection" instead of "object orientation".
(Please note that I've checked a number of tutorials and articles about reflection already to get the answer to this issue but they all talk about what it is and what's the reason behind it(say using it as a documenter) and so on.)
Aucun commentaire:
Enregistrer un commentaire