3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php echo '<form action="" method="post">'; echo '<fieldset>'; echo '<legend>Калькулятор (с использованием 1-го числа)</legend>'; echo '<input type="text" name="c" size="8" />'; echo '<select name="d">'; echo '<option value="na"> </option>'; echo '<option value="cos">cos</option>'; echo '<option value="sin">sin</option>'; echo '<option value="sqr2">x&#178;</option>'; echo '<option value="sqr3">x&#179;</option>'; echo '<option value="sqrt">&#172;</option>'; echo '</select>'; echo '<input type="submit" value="=" />'; $c = $_POST['c']; $d = $_POST['d']; if (isset($_POST['c'])) { switch($d) { case 'na': echo "Виберите действие!"; break; case 'cos': $result6 = cos($c); echo "cos($c) = <b>$result6</b>"; break; case 'sin': $result5 = sin($c); echo "sin($c) = <b>$result5</b>"; break; case 'sqr2': $result8 = pow($c,2); echo "($c)&#178; = <b>$result8</b>"; break; case 'sqr3': $result9 = pow($c,3); echo "($c)&#179; = <b>$result9</b>"; break; case 'sqrt': $result7 = sqrt($c); echo "Корень($c) = <b>$result7</b>"; break; return; } } echo '</fieldset></form>'; echo '<form action="" method="post">'; echo '<fieldset>'; echo '<legend>Калькулятор (с использованием 2-х чисел)</legend>'; echo '<input type="text" name="a" size="8" />'; echo '<select name="q">'; echo '<option value="no"> </option>'; echo '<option value="add">+</option>'; echo '<option value="min">-</option>'; echo '<option value="um">*</option>'; echo '<option value="pod">&#247;</option>'; echo '</select>'; echo '<input type="text" name="b" size="8" />'; echo '<input type="submit" value="=" />'; $a = $_POST['a']; $b = $_POST['b']; $q = $_POST['q']; if (isset($_POST['a']) && isset($_POST['b'])) { switch($q) { case 'no': echo "Виберите действие!"; break; case 'add': $result = $a + $b; echo "$a + $b = <b>$result</b>"; break; case 'min': $result1 = $a - $b; echo "$a - $b = <b>$result1</b>"; break; case 'um': $result2 = $a * $b; echo "$a * $b = <b>$result2</b>"; break; case 'pod': if ($b == '' or $b == 0) { echo "Деление на 0 не возможно! <br>"; } else { $result3 = $a / $b; echo "$a / $b = <b>$result3</b>"; } break; } return; } echo '</fieldset></form>'; ?>
based on dN40B
Output for 5.3.0 - 7.2.0
<form action="" method="post"><fieldset><legend>Калькулятор (с использованием 1-го числа)</legend><input type="text" name="c" size="8" /><select name="d"><option value="na"> </option><option value="cos">cos</option><option value="sin">sin</option><option value="sqr2">x&#178;</option><option value="sqr3">x&#179;</option><option value="sqrt">&#172;</option></select><input type="submit" value="=" /> Notice: Undefined index: c in /in/PNcjd on line 16 Notice: Undefined index: d in /in/PNcjd on line 17 </fieldset></form><form action="" method="post"><fieldset><legend>Калькулятор (с использованием 2-х чисел)</legend><input type="text" name="a" size="8" /><select name="q"><option value="no"> </option><option value="add">+</option><option value="min">-</option><option value="um">*</option><option value="pod">&#247;</option></select><input type="text" name="b" size="8" /><input type="submit" value="=" /> Notice: Undefined index: a in /in/PNcjd on line 65 Notice: Undefined index: b in /in/PNcjd on line 66 Notice: Undefined index: q in /in/PNcjd on line 67 </fieldset></form>
Output for 4.3.0 - 5.2.17
<form action="" method="post"><fieldset><legend>Калькулятор (с использованием 1-го числа)</legend><input type="text" name="c" size="8" /><select name="d"><option value="na"> </option><option value="cos">cos</option><option value="sin">sin</option><option value="sqr2">x&#178;</option><option value="sqr3">x&#179;</option><option value="sqrt">&#172;</option></select><input type="submit" value="=" /> Notice: Undefined index: c in /in/PNcjd on line 16 Notice: Undefined index: d in /in/PNcjd on line 17 </fieldset></form><form action="" method="post"><fieldset><legend>Калькулятор (с использованием 2-х чисел)</legend><input type="text" name="a" size="8" /><select name="q"><option value="no"> </option><option value="add">+</option><option value="min">-</option><option value="um">*</option><option value="pod">&#247;</option></select><input type="text" name="b" size="8" /><input type="submit" value="=" /> Notice: Undefined index: a in /in/PNcjd on line 65 Notice: Undefined index: b in /in/PNcjd on line 66 Notice: Undefined index: q in /in/PNcjd on line 67 </fieldset></form>