fruits.php - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of fruits.php.php

  1. <?php
  2. # 1. PHP is written first
  3.  
  4. $fruits = [
  5.     'apple',
  6.     'banana',
  7.     'pear',
  8.     'watermelon'
  9. ];
  10.  
  11. $title = 'Website Example';
  12. # 2. HTML goes last
  13. ?>
  14. <html>
  15. <head>
  16.     <title><?= $title ?></title>
  17. </head>
  18. <body>
  19.     <h1>Fruits</h1>
  20.     <ul>
  21.         <?php foreach ($fruits as $fruit): ?>
  22.         <li><?= $fruit ?></li>
  23.         <?php endforeach; ?>
  24.     </ul>
  25. </body>
  26. </html>
File Description
  • fruits.php
  • PHP Code
  • 25 Apr-2019
  • 378 Bytes
You can Share it: