A programming idiom is the usual way to code a task in a specific language. For example a loop is often written like this in C:
for (i=0; i<10; i++)
PHP will understand a similar construct:
for ($i = 1; $i <= 10; $i++)
But it is discouraged in PHP for looping over an array. In this case you would use:
foreach ($arr as $value)
Whereas in Ruby, you would use:
(1..10).each
for the loop, or:
array.each
There are many many possibilities to write a loop in those languages. Using the idiom makes it immediately identifiable by experienced readers. They can then spend their time on more important problems.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…