In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
The main content of this article is "how to write the infinite classification of PHP", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to write PHP infinite classification"!
The copy code is as follows:
Cool back to cool, but those articles provide unlimited classification of class-related operations are a bit frustrating, directly encapsulating the database operations. That is to say, other people want to use you as a class and build the same watch as you. It's TM disgusting. Because the project needs to be used, so I wrote a PHP infinite classification class (also known as tree class), there is no database operation, only need to instantiate the result set, that is, the tree array. Then execute the leaf method or navi method to get the desired results. Please look at the source code and present the corresponding template recursion method of the smarty template engine after reading it.
The copy code is as follows:
How to use the PHP infinite classification in smarty:
The copy code is as follows:
$result=$db- > query (…) ; / / the result set is obtained by query here. Note that the result set is an array.
$tree= new Tree ($result)
$arr=$tree- > leaf (0)
$nav=$tree- > navi (15)
$smarty- > assign ('arr',$arr)
$smarty- > assign ('nav',$nav)
$smarty- > display ('test.html')
Recursion in the smarty template is as follows:
The copy code is as follows:
->
Reprint please state that it is from kvoid.com.
Of course, you can also change the recursive method to be free with the tags you want. The recursive method of HTML+PHP mixing is not posted here, and I don't bother to write it. I hate it most and look disgusting. Here I recommend the SpeedPHP framework of jake predecessors. Because the default engine is smarty, my PHP infinite classification is fully compatible with the SP framework. Similarly, jquery's treeview plug-in and drop-down menu plug-in are also perfectly supported.
By the way, it is recommended to use the powerful caching function of Smarty. Caching is the king.
At this point, I believe you have a deeper understanding of "how to write the infinite classification of PHP". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.