Php traverses all elements in the class. Php traversal method of all elements contained in the class. This article describes the methods of all elements contained in the php traversal class. Share it with you for your reference. The specific analysis is as follows: the php traversal class contains all the elements of the method, php
This example describes how to traverse all elements in the php class. Share it with you for your reference. The specific analysis is as follows:
All elements in the php class can be output as key-value.
Class MyTestClass {const TESTVAR1 = 1001; const TESTVAR2 = 1002; const TESTSTR1 = 'hello';} $ rc = new ReflectionClass ('mytestclass '); $ v = $ rc-> getConstants (); asort ($ v); // sort by value // ksort ($ v ); // sort by keyforeach ($ v as $ name = >$ value) {echo "$ name = >$ value \ n ";}
The running result is as follows:
TESTSTR1 => helloTESTVAR1 => 1001TESTVAR2 => 1002
I hope this article will help you with php programming.
Examples in this article describes how to traverse all elements contained in the php class. Share it with you for your reference. The specific analysis is as follows: here...