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. $cis = $cislo;
  24. $max = 0;
  25. while ($cislo != 0) {
  26. if (($cislo % 10) > $max)
  27. $max = ($cislo % 10);
  28. $cislo = $cislo / 10;
  29. }
  30. print_r($max);
  31. }
  32. print_r(maxcif(239172435));
  33. print_r("\n");
  34. print_r("Задание 4");
  35. print_r("\n");
  36. for ($i=1; $i <= 9; $i++ ) {
  37.   for ($k=1; $k <= 9; $k++) {
  38.     print_r("$i x $k = " . $i * $k);
  39.     print_r("\n");
  40.   }
  41. }
  42. print_r("\n");
  43. print_r("Задание 5");
  44. print_r("\n");
  45. $arr = [1, 4, 15, 23, 46, 48, 55];
  46. $max= 0;
  47. foreach($arr as $k => $v)
  48. if ($k % 2 === 0 && $max < $v)
  49. $max = $v;
  50. print_r($max);
  51. print_r("\n");
  52. print_r("Доп Задание");
  53. print_r("\n");
  54. function sum($n)
  55. {
  56.     if ($n === 1) {
  57.         return 1;
  58.     }
  59.     return $n + sum($n-1);
  60. }
  61. print_r(sum(321));
  62. print_r("\n");
  63. print_r("Задание 6");
  64. print_r("\n");
  65. $array = array(array("яблоко"), array("шуруповерт"), array("пейзаж"), array("жасмин"), array("велосипед"));
  66. $vowels = array("у", "ё", "е", "ы", "а", "о", "э", "я", "и", "ю");
  67. if (in_array($vowels, $array[0])){
  68.     print_r("яоо");
  69. }
  70. if (in_array($vowels, $array[1])){
  71.     print_r("ууое");
  72. }
  73. if (in_array($vowels, $array[2])){
  74.     print_r("еа");
  75. }
  76. if (in_array($vowels, $array[3])){
  77.     print_r("аи");
  78. }
  79. if (in_array($vowels, $array[4])){
  80.     print_r("еоие");
  81. }
  82.  
  83.  
  84.  
  85.  
  86.  
File Description
  • Test
  • PHP Code
  • 23 Apr-2023
  • 1.59 Kb
You can Share it: