lab1 - 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 lab1.php
- <?php
- #1.1
- $a = 10;
- echo $a."\n";
- echo "\n";
- #1.2
- $b = 20;
- echo ($b - $a)."\n";
- echo ($b + $a)."\n";
- echo ($b * $a)."\n";
- echo ($b / $a)."\n";
- echo "\n";
- #1.3
- $c = 40;
- $d = 60;
- $result = $c + $d;
- echo $result."\n";
- echo "\n";
- #1.4
- $a1 = 3;
- $b1 = 1;
- $c1 = $a1 - $b1;
- $d1 = 15;
- $result1 = $c1 + $d1;
- echo $result1."\n";
- echo "\n";
- #2.1
- $text = "Привет, Мир!";
- echo $text."\n";
- #2.2
- $text1 = "Привет, ";
- $text2 = "Мир!";
- echo $text1.$text2."\n";
- #2.3
- $name = "Вероника";
- echo "Привет, $name!"."\n";
- #2.4
- $age = "21";
- echo "Мне $age год"."\n";
- echo "\n";
- #3.1
- $text3 = "HelloWorld";
- #3.2
- echo $text3[1], $text3[5], $text3[7]."\n";
- echo "\n";
- #3.3
- echo str_replace($text3[0], "T", $text3)."\n";
- echo "\n";
- #3.4
- $num = '8568';
- echo array_sum(str_split($num))."\n";
- echo "\n";
- #4.1
- echo (60 * 60 * 24)."\n";
- echo "\n";
- #4.2
- $hour = 19;
- $min = 43;
- $second = 07;
- echo "$hour:$min:$second"."\n";
- echo "\n";
- #4.3
- $z = 4;
- echo pow($z, 2)."\n";
- echo "\n";
- #4.4
- $var = 47;
- $var += 7;
- $var -= 18;
- $var *= 10;
- $var /= 20;
- echo $var."\n";
- echo "\n";
- #4.5
- $text = 'Я';
- $text .= ' хочу';
- $text .= ' знать';
- $text .= ' PHP!';
- echo $text;
- ?>