I got a bit bored today, so I decided to write a simple function to mock the function of the Pythagorean Theorem.

<?php function pythagorean ($a, $b, $c) { (!$a) ? $out = sqrt($c * $c - $b * $b) : null; (!$b) ? $out = sqrt($c * $c - $a * $a) : null; (!$c) ? $out = sqrt($a * $a + $b * $b) : null; return $out; } ?>

Using the function, you can find the hypotenuse when you know the legs are 3 and 4 using the following snippet of code:

echo pythagorean(3, 4, false);

Feel free to use it however you wish. You might also want to round the answer to the nearest integer using:

echo round(pythagorean(3, 4, false));