Expose the principle of php unlimited classification

Source: Internet
Author: User
PHP's unlimited classification is important in both work and study. many people only know how to write, but do not know why. today we will explore his deep-seated principles. Concept

The concept of php's unlimited classification is like a tree. the tree has its own root, and then the trunk and branches are on the leaves. the more forward, the more dense the tree is. this is the same as classification, the more detailed the classification, the more columns, the more pre-installed WINDOWS operating systems, you can try to create a new folder in a folder and then create one in the new folder. You will be able to understand what an infinitely level is.

Principle

First, let's assume there is such a three-level classification: news> PHP News> PHP6.0. If we want to find the news "PHP6.0 has come out", we can click the news first, and then click the PHP news to find out, that is, we can find it through the grandfather class level-1, in turn, as long as we know the parent class of a subclass, we can find it. In this way, when designing a database, we can design a parent class id field to implement the unlimited classification function. the parent class ID in the database is particularly important, next, we can use recursive and iterative methods to create an infinite classification. For a deep understanding, we can use the family tree and the descendant tree as a metaphor.

Genealogy treeIs one of the manifestations of Infinitus classification, and the other isDescendant tree.The differences can also be seen from the meaning of Chinese.

The family tree is now popular in many places. how to build a family tree is to find a ancestor for yourself, and to build a system from generation to generation, which is called a family tree. The family tree is similar,Search for the parent node from a node and find the parent node of the parent node until it is not found. According to this search, a tree-like structure is called a genealogy tree.

On the contrary, a descendant tree is similar to a genetic map in a biological book,Start from a node to find its child node, and find the child node of the child node until the search is complete. The tree structure is called a descendant tree.

Recursive flowchart

Related articles:

Php recursion to implement an infinite classification tree

Php uses recursive methods to implement unlimited classification

Php unlimited classification implementation method analysis

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.