Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

PHP manual gems

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:

<?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

Name: Anonymous 2010-01-05 16:53

look on line 11 of shiichan

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List