Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Purpose of PHP ReflectionClass Apart from Documenting

Posted on 2009-06-30
4
Medium Priority
?
397 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

715 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