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

  1. <?php
  2.  
  3. print_r("Задание 1");
  4. print_r("\n");
  5. $result = 4**2 + 6**2;
  6. print_r($result);
  7. print_r("\n");
  8. print_r("Задание 2");
  9. print_r("\n");
  10. function difference ($a, $b)
  11. {
  12.         if ($a > $b) {
  13.                 return $a;
  14.         }
  15.         return $b;
  16. }
  17. print_r(difference (15, 4));
  18. print_r("\n");
  19. print_r("Задание 3");
  20. print_r("\n");
  21. function maxcif($cislo)
  22. {
  23. $max = 0;
  24. while ($cislo != 0) {
  25. if (($cislo % 10) > $max)
  26. $max = ($cislo % 10);
  27. $cislo = $cislo / 10;
  28. }
  29. print_r($max);
  30. }
  31. print_r(maxcif(239172435));
  32. print_r("\n");
  33. print_r("Задание 4");
  34. print_r("\n");
  35. for ($i=1; $i <= 9; $i++ ) {
  36.   for ($k=1; $k <= 9; $k++) {
  37.     print_r("$i x $k = " . $i * $k);
  38.     print_r("\n");
  39.   }
  40. }
  41. print_r("\n");
  42. print_r("Задание 5");
  43. print_r("\n");
  44. $arr = [1, 4, 15, 23, 46, 48, 55];
  45. $max= 0;
  46. foreach($arr as $k => $v)
  47. if ($k % 2 === 0 && $max < $v)
  48. $max = $v;
  49. print_r($max);
  50. print_r("\n");
  51. print_r("Доп Задание");
  52. print_r("\n");
  53. function sum($n)
  54. {
  55.     if ($n === 1) {
  56.         return 1;
  57.     }
  58.     return $n + sum($n-1);
  59. }
  60. print_r(sum(321));
  61. print_r("\n");
  62. print_r("Задание 6");
  63. print_r("\n");
  64. $array = array(array("яблоко"), array("шуруповерт"), array("пейзаж"), array("жасмин"), array("велосипед"));
  65. $vowels = array("у", "ё", "е", "ы", "а", "о", "э", "я", "и", "ю");
  66.  
  67.  
  68.  
  69.  
  70.  
File Description
  • Test
  • PHP Code
  • 24 Apr-2023
  • 1.29 Kb
You can Share it: