Examples
Many examples exist within the Reflection documentation, typically within the __construct documentation for each class.
Example #1 Reflection Example from Shell (a Terminal)
$ php --rf strlen $ php --rc finfo $ php --re json $ php --ri dom
The above example will output something similar to:
Function [ <internal:Core> function strlen ] { - Parameters [1] { Parameter #0 [ <required> $str ] } } Class [ <internal:fileinfo> class finfo ] { - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [0] { } - Methods [4] { Method [ <internal:fileinfo, ctor> public method finfo ] { - Parameters [2] { Parameter #0 [ <optional> $options ] Parameter #1 [ <optional> $arg ] } } Method [ <internal:fileinfo> public method set_flags ] { - Parameters [1] { Parameter #0 [ <required> $options ] } } Method [ <internal:fileinfo> public method file ] { - Parameters [3] { Parameter #0 [ <required> $filename ] Parameter #1 [ <optional> $options ] Parameter #2 [ <optional> $context ] } } Method [ <internal:fileinfo> public method buffer ] { - Parameters [3] { Parameter #0 [ <required> $string ] Parameter #1 [ <optional> $options ] Parameter #2 [ <optional> $context ] } } } } Extension [ <persistent> extension #23 json version 1.2.1 ] { - Constants [10] { Constant [ integer JSON_HEX_TAG ] { 1 } Constant [ integer JSON_HEX_AMP ] { 2 } Constant [ integer JSON_HEX_APOS ] { 4 } Constant [ integer JSON_HEX_QUOT ] { 8 } Constant [ integer JSON_FORCE_OBJECT ] { 16 } Constant [ integer JSON_ERROR_NONE ] { 0 } Constant [ integer JSON_ERROR_DEPTH ] { 1 } Constant [ integer JSON_ERROR_STATE_MISMATCH ] { 2 } Constant [ integer JSON_ERROR_CTRL_CHAR ] { 3 } Constant [ integer JSON_ERROR_SYNTAX ] { 4 } } - Functions { Function [ <internal:json> function json_encode ] { - Parameters [2] { Parameter #0 [ <required> $value ] Parameter #1 [ <optional> $options ] } } Function [ <internal:json> function json_decode ] { - Parameters [3] { Parameter #0 [ <required> $json ] Parameter #1 [ <optional> $assoc ] Parameter #2 [ <optional> $depth ] } } Function [ <internal:json> function json_last_error ] { - Parameters [0] { } } } } dom DOM/XML => enabled DOM/XML API Version => 20031129 libxml Version => 2.7.3 HTML Support => enabled XPath Support => enabled XPointer Support => enabled Schema Support => enabled RelaxNG Support => enabled
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-reflection.examples.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.