Source Code for /public/04-includes-and-functions/cap-img-demo.php

<?php
/*
 * Load our cap_img() function so we can make a gallery. We use
 * `require_once` so that we don't accidentally load it twice,
 * and so that if it fails to load the page stops here!
 */
require_once('cap-img.php');
?>

<p>
  Things in my fruitbowl:
</p>

<div class="gallery">
  <?php
  cap_img( '/img/fruit/apple.jpg', 'A red apple',
          'From the tree in my back yard.' );

  cap_img( '/img/fruit/bananas.jpg', 'Two ripe bananas',
          "They're my favorite fruit." );

  cap_img( '/img/fruit/plums.webp', 'A bowl of purple plums',
          'I enjoy making jam every Autumn.' );

  cap_img( '/img/fruit/kiwi.jpg', 'A halved kiwi fruit',
          'I wish these grew in my part of the world.' );
  ?>
</div>