| Cycles | Цикли |
|
I tell you, earlier, PHP is a server side programming language. Programs or scripts are interpreted in special daemon , and do some work. Like mostly others programming languages , PHP contain cycle constructions in few variants. FOR,WHILE,DO..WHILE,FOREACH cycle with precondition WHILEif logical expression is true ,than do cycle script,if false go to another operator(example 1) |
Як вам раніше уже писав, PHP являє собою мову програмування на стороні сервера. Програми або скрипти інтерпретуються в спеціальному демоні та виконують певну роботу. Як і більшість інших мов програмування, PHP містять циклові конструкції в декількох варіантах. FOR,WHILE,DO-WHILE,FOREACH цикл з передумовою WHILEякщо логічний вираз істинний, ніж робити сценарій циклу, якщо ложно перейти до іншого оператора(приклад 1) |
<?php
while(logical epression){
//cycle script
}
//or
while(logical expression):
//cycle script
endwhile;
cycle with aftercondition DO..WHILElogical expression will be checked after cycle script done(example 2) |
цикл з післяумовою DO..WHILEлогічний вираз буде перевірено після завершення сценарію циклу(приклад 2) |
<?php
do{
//cycle script
}while(logical epression)
сycle with counter FORused when need to do cycle script some count of times(example 3) |
цикл з лічильником FORвикористовується, коли потрібно виконувати сценарій циклу кілька разів(приклад 3) |
<?php
for(initializing_commands;cycle condition;after_script_commands){
//cycle script
}
//or
for(initializing_commands;cycle condition;after_script_commands):
//cycle script
endfor;
array overflow cycle FOREACHThe name of this cycle speaks for itself.(example 4) |
цикл перебору масиву FOREACHНазва цього циклу говорить сама за себе(приклад 4) |
foreach (array as $key=>$value){
// cycle script
}
///or
foreach (array as $value){
// cycle script
}
In second part of this article we will spoke about 'break' and 'continue' constructions, and I will prepare for you some examples with all cycles constructions.
У другій частині цієї статті ми говоримо про конструкції "break" та "continue", і Я підготую вам кілька прикладів з усіма циклічними конструкціями.