PHP Loops - do, while, foreach and for .
Welcome to PHP programming,
We explain PHP Loops - do, while, foreach and for in this tutorial
In PHP looping statements are used to execute the same block of code a specified number of
times.
Following are the looping statements in PHP:
1) while
2) do..while
3) for
4) foreach
1) The while loop
loops through a block of code if and as long as a specified condition is true.
Syntax:
while(condition)
code to be executed;
Let us write a simple PHP code that outputs the numbers from 1 to 5 using while loop
Save it in our server i.e., xampp/htdocs
Run the code using url http://localhost/phpwhile.php
This is how the while loop works with PHP script.
2) The do..while loop
loops through a block of code atleast once and then repeats the loop as long as a special
condition is true.
Syntax:
do
{
code to be executed;
}
while(condition);
Let us write a simple PHP code that displays a numbers from 1 to 4 using do..while loop.
Save it in our server i.e., xampp/htdocs
Run the code using the url http://localhost/phpdowhile.php
This is how do..while loop works with PHP script.
3) The for loop
loops through a block of code a specified number of times.
Syntax:
for(initialization; condition; increment)
{
code to be executed;
}
a) The for loop has three parameters.
b) The first parameter initializes variables
c) The second parameter holds the condition
d) The third parameter contains the increment required to implement the loop.
e) If more than one variable is included in the initialization or the increment parameter,
they should be seperated by commas.
f) The condition must evaluate to true or false.
Let us write a simple PHP code that displays the text "Welcome to PHP Programming" 5 times using for loop
Save it in our server i.e., xampp/htdocs
Run the code using the url http://localhost/phpfor.php
This is how for loop works with PHP script.
4) The foreach loop
loops through a block of code for each element in an array.
Syntax:
foreach(array as value)
{
code to be executed;
}
For every loop, the values of the current array element is assigned to $value and the array pointer
is moved by one.
Let us write a simple #PHP code that outputs texts stored in the array using foreach loop
Save it in our server i.e, xampp/htdocs
Run the code using the url http://localhost/phpforeach.php
This is how foreach loop works in PHP script.
Thank You......
For source code kindly refer www.studentprojects.live
Do you have Any queries? Contact us in Whatsapp :- +91-9972853368
#studentprojects #phpcode
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «PHP Loops - do, while, foreach and for .», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.