Name: Anonymous 2010-01-04 0:47
Every now and then, one comes across these mind-blowingly profound comments in the PHP manual. Post your discoveries here!
I'll start with this: (from http://www.php.net/manual/en/function.abs.php#94768)
Here is a simple function to make positives to negative and negatives to positive. This is function:
You can use this code:
The output is:
-5
;
Because 5 + -10 = -10
I'll start with this: (from http://www.php.net/manual/en/function.abs.php#94768)
Here is a simple function to make positives to negative and negatives to positive. This is function:
<?php
function turn($x)
{
$y = abs($x);
if ($y == $x)
return "-$y";
else
return "$y";
}
?>You can use this code:
<?php
echo turn(-5) + turn(10);
?>The output is:
-5
;
Because 5 + -10 = -10