PHP Recursive implementation of infinite-level classification of the development process and sample code

Source: Internet
Author: User
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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.