<?php define('КАТЕТ1','a'); define('КАТЕТ2','b'); define('ГИПОТЕНУЗА','c'); $umnogenie1=a*a; $umnogenie2=b*b; $umnogenie3=c*c; $slogenie=$umnogenie1+$umnogenie2; $slogenie=$umnogenie3; echo"$slogenie=$umnogenie3"; ?> 

It should turn out on the server a^2+b^2=c^2 , and it turns out 0=0 . What am I doing wrong? Help me please.

  • 2
    Some crazy code, why are the names of constants in Cyrillic? What the "a * a"? Do you multiply characters? Or did I not understand something? - Elime
  • the code is hard, ah, +1 - nullptr

4 answers 4

 <?php if (!empty($_POST['katet'] && $_POST['katet2'] && $_POST['gipot'])) { $k1 = $_POST['katet']; $k2 = $_POST['katet2']; $g = $_POST['gipot']; $r = $k1*$k1+$k2*$k2 ." = ". $g*$g; echo $r; } ?> <form action="index.php method="POST"> <input type="number" name="katet"> <input type="number" name="katet2"> <input type="number" name="gipot"> <input type="submit"> </form> 
     $a = 3; $b = 4; $c = 5; echo $a*$a+$b*$b ." = ". $c*$c; 
       class Geometry { /** * @param array $cathetus * @param bool|integer $hypothenuse * @return bool|string */ public static function pifagorTheorem($cathetus = [], $hypothenuse = false) { if (count($cathetus) != 2 || !$hypothenuse) { return 'No result'; } return strval((pow($cathetus[0], 2) + pow($cathetus[1], 2)) == pow($hypothenuse, 2)); } } echo Geometry::pifagorTheorem([3, 4], 5); 
         <?php function pythagoras($a,$b,$c,$precision=4) { ($a) ? $a = pow($a,2) : $find .= 'a'; ($b) ? $b = pow($b,2) : $find .= 'b'; ($c) ? $c = pow($c,2) : $find .= 'c'; switch ($find) { case 'a': return round(sqrt($c - $b),$precision); break; case 'b': return round(sqrt($c - $a),$precision); break; case 'c': return round(sqrt($a + $b),$precision); break; } return false; } /* echo pythagoras(5,false,13); // 12 */