SENTENCE REPETITION

      Okay. ,. This time I gave a tutorial on perulangan.Php has a function to repeat a word or phrase as a predetermined or not. At least, there are three types of commonly used methods of repetition. Here we discuss one by one:

  1. repetition FOR


FOR is a form of repetition to repeat a word or command with the number of repetitions that are already known or determined.
The following general form:
FOR (early; Events; additions)
{
The code will be on the run
}

Here I give you an example. ,.
Give pengulangan.php file name, then copy the following script:

<?
echo "Repetition FOR";
for ($ try = 1; $ try <= 10; $ try + +) {
echo "$ try";
}
?>
Then, enter the URL address of your browser, the following address:
http://localhost/pengulangan.php
It will appear like this:




  2. While repetition

While a function is also used to repeat a perinta. It's just that distinguishes it for, is to command the final value is not known. So to conclude while functioning as a command to run continuously for the condition is true.

The following general form:
While (condition) {
Code to be executed;
}

Here I give an example and create the code name while.php:
<?
$ try = 1;
while ($ try <= 10) {
echo "number. $ trying Reviews";
$ try + +;
}
?>

Then, enter the URL address of your browser, the following address:
http://localhost/while.php
It will appear like this:



3. Repetition Do ... While

Do ... while function to execute a command only in the right conditions, and will be stopped if the condition is false.
The following general form:
While (condition)
do {
Code to be executed
}

Here I will give an example and give the file name dowhile.php:
<?

$ try = 1;
do {
echo "$ number try Repetition Reviews";
$ try + +;
}
while ($ try <= 10);
$ stop = 10;
do {
echo "Repetition Reviews will stop if the condition is false";
$ stop + +;
}
while ($ stop <= 8);

?>

Then, enter the URL address of your browser, the following address:
http://localhost/dowhile.php
It will appear like this:


So first tutorial I give may be useful.

Post a Comment