In some complex systems, it is required to classify the information columns infinitely, in order to enhance the flexibility of the system. Recursive, Simple is a program code repeated calls, when the code is written into a custom function, the parameters and other variables are saved, function repeatedly called functions, until a certain condition to jump out, return the corresponding data. So how does PHP implement an infinite class classification?
First step: Download the PHP recursive implementation of the infinite class library that we need to use for this lesson: http://www.php.cn/xiazai/leiku/292
The second step: After the download is complete, find the PHP class file, unzip to the local server, create a new PHP file!
Step Three: We call this class in this new file, and instantiate this class:
<?phpinclude_once "cate.php";//Introduce class file $obj = new category; Instantiate $obj->unlimitedforlayer ($cate); Var_dump ($obj->unlimitedforlayer ($cate));//var_dump ($obj Unlimitedforlevel ($cate));//var_dump ($obj->getparents ($cate, 7));//var_dump ($obj->getchildsid ($cate, 2)); /var_dump ($obj->getchilds ($cate, 2));?>
The results of the operation are as follows: