Solved

Purpose of PHP ReflectionClass Apart from Documenting

Posted on 2009-06-30
4
388 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 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

623 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