siteIcon

Tech Novice Tools

PHP Apps

burgerIcon

Marco Poloexplorer

Stage 1:
Repetition in the 'Cave of Wonders'

About the app

Is there an echo in here?!

Yep, and it's in a loop...which, along with some PHP variables, will allow us to write many list items within an ordered list!

You will begin to PHP!

'Cave of Wonders' Commentary:

First of all, look at our heart-y command above. It is using an 'HTML entity' to get the symbol. We styled it to be red with an 'inline style' which generally, is not a great practice, but we did it to show that we can.

On to PHP!

This time, after the page loads, a RMC reveals how an 'ordered list' is created as normal using PHP, but the 'list items' inside were made using a loop in PHP.

Here's the loopy code in context of the 'ordered list:'

                                
<ol>
<?php          
    for($i = 1; $i <= 12; $i++){
        echo("<li>Marco? .... Polo!!</li>");
    }              
?>
</ol>                                

If you've had training in other languages such as Java or JavaScript, you may notice the common 'for loop' (aka, fixed iteration loop) which is using a control variable, i.

Note that variables in PHP are prefixed with a '$,' perhaps reminding us how much money we will make when we get fluent in it!

It's also worth noting that the 'echo' command we used in the previous app is a function, and in this setting we chose to use it with () like a normal good little function. However, we can just use it with delimiting quotes, which is slightly more convenient.

Twelve repetitions might not have been a big deal to type out manually, but What if we had to generate a list of items like birthdates like we did in the Birthday App?!

Are you beginning to see how P-O-W-E-R-F-U-L PHP can be?

12/16/19


  1. Marco? .... Polo!!
  2. Marco? .... Polo!!
  3. Marco? .... Polo!!
  4. Marco? .... Polo!!
  5. Marco? .... Polo!!
  6. Marco? .... Polo!!
  7. Marco? .... Polo!!
  8. Marco? .... Polo!!
  9. Marco? .... Polo!!
  10. Marco? .... Polo!!
  11. Marco? .... Polo!!
  12. Marco? .... Polo!!