课程: PHP for WordPress (2020)

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Loops

Loops

- [Instructor] Loops are a fundamental part of PHP and WordPress specifically. In fact, the important portion of WordPress code is actually called the loop. And we'll look at two types of loops, while loops and foreach loops. But first, let's look at what they are. An if statement will execute a piece of code once if a condition is true, but loops will continue to execute a piece of code until the condition becomes false. There are lots of applications for loops, like enumerating, performing repetitive math, and listing a set of items, but in WordPress, loops are most often used to process arrays. Now before we get into actual code examples, let's look at the structure of each. While loops will do something while a condition is true, and these are general-purpose loops used for math, enumeration, or anything that you can think of. Foreach loops are loops that do something for each item in a list, and these are used to process…

内容