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.
Result of php executing
Full code of Test.php
- <?php
- print_r("Задание 1");
- print_r("\n");
- $result = 4**2 + 6**2;
- print_r($result);
- print_r("\n");
- print_r("Задание 2");
- print_r("\n");
- function difference ($a, $b)
- {
- if ($a > $b) {
- return $a;
- }
- return $b;
- }
- print_r(difference (15, 4));
- print_r("\n");
- print_r("Задание 3");
- print_r("\n");
- function maxcif($cislo)
- {
- $max = 0;
- while ($cislo != 0) {
- if (($cislo % 10) > $max)
- $max = ($cislo % 10);
- $cislo = $cislo / 10;
- }
- print_r($max);
- }
- print_r(maxcif(239172435));
- print_r("\n");
- print_r("Задание 4");
- print_r("\n");
- for ($i=1; $i <= 9; $i++ ) {
- for ($k=1; $k <= 9; $k++) {
- print_r("$i x $k = " . $i * $k);
- print_r("\n");
- }
- }
- print_r("\n");
- print_r("Задание 5");
- print_r("\n");
- $arr = [1, 4, 15, 23, 46, 48, 55];
- $max= 0;
- foreach($arr as $k => $v)
- if ($k % 2 === 0 && $max < $v)
- $max = $v;
- print_r($max);
- print_r("\n");
- print_r("Доп Задание");
- print_r("\n");
- function sum($n)
- {
- if ($n === 1) {
- return 1;
- }
- return $n + sum($n-1);
- }
- print_r(sum(321));
- print_r("\n");
- print_r("Задание 6");
- print_r("\n");
- $array = array(array("яблоко"), array("шуруповерт"), array("пейзаж"), array("жасмин"), array("велосипед"));
- $vowels = array("у", "ё", "е", "ы", "а", "о", "э", "я", "и", "ю");