lab5.1 - 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 lab5.1.php

  1. <?php
  2.     $a = 3;
  3.     echo $a, PHP_EOL;
  4.     $a = 10;
  5.     $b = 2;
  6.     echo $a + $b, ' ', $a - $b, ' ', $a * $b, ' ', $a / $b, PHP_EOL;
  7.     $c = 15;
  8.     $d = 2;
  9.     $result = $c + $d;
  10.     echo $result, PHP_EOL;
  11.     $a = 10;
  12.     $b = 2;
  13.     $c = 5;
  14.     echo $a + $b + $c, PHP_EOL;
  15.     $a = 17;
  16.     $b = 10;
  17.     $c = $a - $b;
  18.     $d = 7;
  19.     $result = $c + $d;
  20.     echo $result, PHP_EOL;
  21.     $text = 'Привет, Мир!';
  22.     echo $text, PHP_EOL;
  23.     $text1 = 'Привет, ';
  24.     $text2 = 'Мир!';
  25.     echo $text1 . $text2, PHP_EOL;
  26.     $name = 'Арсений';
  27.     echo 'Привет, ' . $name . '!', PHP_EOL; 
  28.     $age = 21;
  29.     echo 'Мне ' . $age . ' лет!', PHP_EOL;
  30.     $text = 'abcde';
  31.     echo $text[0] . ' ' . $text[2] . ' ' . $text[4], PHP_EOL;
  32.     $text[0] = '!';
  33.     echo $text, PHP_EOL;
  34.     $num = '12345';
  35.     echo $num[0] + $num[1] + $num[2] + $num[3] + $num[4];
  36.     
  37.     function to_sec()
  38. ?>
File Description
  • lab5.1
  • PHP Code
  • 11 Apr-2024
  • 916 Bytes
You can Share it: