Solved

Purpose of PHP ReflectionClass Apart from Documenting

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
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.

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now