Solved

Purpose of PHP ReflectionClass Apart from Documenting

Posted on 2009-06-30
4
372 Views
Last Modified: 2013-12-13
Dear all,

   I'm new to the concept of reflection. I have read into the concept but I'm not sure why it should be used apart from documenting the code.

   Invoking a method of a certain class via PHP ReflectionClass is more complicated than simply invoking the method by instantiating the class itself. So, why is ReflectionClass necessary?

   I understand that reflection can avoid hardcoding. Could you offer some examples of using the PHP ReflectionClass which makes coding more efficient?

Regards,
Ming
0
Comment
Question by:tsuiwaiming
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 500 total points
ID: 24745930
It is used in metaprogramming, i.e. when "programming the program".

http://en.wikipedia.org/wiki/Metaprogramming

You can find some examples of the usage here:

http://php.net/oop5.reflection 
0
 

Author Comment

by:tsuiwaiming
ID: 24746444
Dear cxr,

   Thanks for your message. I had read briefly the articles in the sources you offered while I was writing my question, though. May I clarify my question a bit? I'd like to know how PHP ReflectionClass helps in, say, a single webpage in which rows of a database are selected or updated.

Regards,
Ming
0
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24746622
I can't imagine how ReflectionClass would be helpfull in that scenario. I'm not saying it can not be helpfull, I just can't imagine how. :)
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question