task_2 - 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 task_2.php

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5. </head>
  6. <body>
  7. <?php
  8. $m = rand(4, 8);
  9. $n = rand(4, 8);
  10. echo("<table style='width: 800px; height: 800px; border: 1px solid black; border-collapse: collapse'>");
  11. for ($i=1; $i<$m+1; $i++) {
  12.     echo("<tr>");
  13.     for ($j=1; $j<$n+1; $j++) {
  14.         if ($i < $j) {
  15.             echo("<td style='background: red; border: 1px solid black'></td>");
  16.         } else {
  17.             echo("<td style='border: 1px solid black'></td>");
  18.         }
  19.     }
  20.     echo("</tr>");
  21. }
  22. echo("</table>");
  23. ?>
  24. </body>
  25. </html>
File Description
  • task_2
  • PHP Code
  • 20 Jan-2022
  • 585 Bytes
You can Share it: