• PHP Nested if Statement
    Nested If You can have if statements inside if statements, this is called nested if statements. ExampleGet your own PHP Server An if inside an if: $a = 13; if ($a > 10) { echo "Above 10"; if ($a > 20) { echo " and also above 20"; } else { echo " but not above 20"; } } Try it Yourself »
    0 Commentaires 0 Parts 4KB Vue 0 Aperçu
  • PHP switch Statement
    The switch statement is used to perform different actions based on different conditions. The PHP switch Statement Use the switch statement to select one of many blocks of code to be executed. Syntax switch (expression) { case label1: //code block break; case label2: //code block; break; case label3: //code block break;...
    0 Commentaires 0 Parts 4KB Vue 0 Aperçu
  • PHP Loops
    In the following chapters you will learn how to repeat code by using loops in PHP. PHP Loops Often when you write code, you want the same block of code to run over and over again a certain number of times. So, instead of adding several almost equal code-lines in a script, we can use loops. Loops are used to execute the same block of code again and again, as long as a certain condition is...
    0 Commentaires 0 Parts 4KB Vue 0 Aperçu
  • PHP while Loop
    The while loop - Loops through a block of code as long as the specified condition is true. The PHP while Loop The while loop executes a block of code as long as the specified condition is true. ExampleGet your own PHP Server Print $i as long as $i is less than 6: $i = 1; while ($i < 6) { echo $i; $i++; } Try it Yourself »...
    0 Commentaires 0 Parts 5KB Vue 0 Aperçu
  • PHP do while Loop
    The do...while loop - Loops through a block of code once, and then repeats the loop as long as the specified condition is true. The PHP do...while Loop The do...while loop will always execute the block of code at least once, it will then check the condition, and repeat the loop while the specified condition is true. ExampleGet your own PHP Server...
    0 Commentaires 0 Parts 5KB Vue 0 Aperçu
  • PHP for Loop
    The for loop - Loops through a block of code a specified number of times. The PHP for Loop The for loop is used when you know how many times the script should run. Syntax for (expression1, expression2, expression3) { // code block } This is how it works: expression1 is evaluated once expression2 is evaluated before each iteration...
    0 Commentaires 0 Parts 4KB Vue 0 Aperçu
  • PHP foreach Loop
    The foreach loop - Loops through a block of code for each element in an array or each property in an object. The foreach Loop on Arrays The most common use of the foreach loop, is to loop through the items of an array. ExampleGet your own PHP Server Loop through the items of an indexed array: $colors = array("red", "green", "blue", "yellow"); foreach ($colors as...
    0 Commentaires 0 Parts 5KB Vue 0 Aperçu
  • PHP Break
    The break statement can be used to jump out of different kind of loops. Break in For loop The break statement can be used to jump out of a for loop. ExampleGet your own PHP Server Jump out of the loop when $x is 4: for ($x = 0; $x < 10; $x++) { if ($x == 4) { break; } echo "The number is: $x <br>"; } Try it Yourself...
    0 Commentaires 0 Parts 5KB Vue 0 Aperçu
  • PHP Continue
    The continue statement can be used to jump out of the current iteration of a loop, and continue with the next. Continue in For Loops The continue statement stops the current iteration in the for loop and continue with the next. ExampleGet your own PHP Server Move to next iteration if $x = 4: for ($x = 0; $x < 10; $x++) { if ($x == 4) {...
    0 Commentaires 0 Parts 4KB Vue 0 Aperçu
  • PHP Functions
    The real power of PHP comes from its functions. PHP has more than 1000 built-in functions, and in addition you can create your own custom functions. PHP Built-in Functions PHP has over 1000 built-in functions that can be called directly, from within a script, to perform a specific task. Please check out our PHP reference for a complete overview of the PHP built-in functions. PHP...
    0 Commentaires 0 Parts 5KB Vue 0 Aperçu
Sociallez https://sociallez.com