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

  1. <?php
  2.  
  3. for ($hours = 1; $hours <= 24; $hours++) {
  4.     echo "Часов: $hours, Стоимость: " . getBodyguardPrice($hours) . "₽\n";
  5. }
  6.  
  7.  
  8. function getBodyguardPrice($hoursCount)
  9. {
  10.     if ($hoursCount == 1) {
  11.         return 5000;
  12.     }
  13.     if ($hoursCount == 2) {
  14.         return 8000;
  15.     }
  16.     if ($hoursCount == 3) {
  17.         return 9000;
  18.     }
  19.     if ($hoursCount < 6) {
  20.         return 9000 + ($hoursCount - 3) * 2500;
  21.     }
  22.     if ($hoursCount == 6) {
  23.         return 15000;
  24.     }
  25.     if ($hoursCount < 10) {
  26.         return 15000 + ($hoursCount - 6) * 2000;
  27.     }
  28.     if ($hoursCount == 10) {
  29.         return 20000;
  30.     }
  31.     if ($hoursCount < 14) {
  32.         return 20000 + ($hoursCount - 10) * 1500;
  33.     }
  34.     if ($hoursCount == 14) {
  35.         return 21000;
  36.     }
  37.     if ($hoursCount < 18) {
  38.         return 21000 + ($hoursCount - 14) * 1300;
  39.     }
  40.     if ($hoursCount == 18) {
  41.         return 23400;
  42.     }
  43.     if ($hoursCount < 24) {
  44.         return 23400 + ($hoursCount - 18) * 1200;
  45.     }
  46.     if ($hoursCount == 24) {
  47.         return 28800;
  48.     }
  49.  
  50.     return 28800 + ($hoursCount - 24) * 1000;
  51.  
  52. }
  53.  
File Description
  • 123
  • PHP Code
  • 15 Sep-2023
  • 1.08 Kb
You can Share it: