Skip navigation.
Home

Wonky Code

That's an ODD piece of code....

Wonky Code

Fabel sent in today's WTF. It short, and it definately made me go WTF... trying to figure out what it does. After looking at it, and looking at it a little more, it appears to check if $x is even or odd. Here's what Fabel had to say:

Heh this wasnt written by any of us in house it was from someone elses code that got used in a credit card validation routine, i noticed it one day and literally went WTF i've never seen anyone use this method to see if a number is odd or not. I had to do a double take to realize what it was checking for im used to seeing either a modulus to check or just a if($x & 1) for checking an odd number.

<?php
if ($x/2 != floor($x/2)) {
  
$digit *= 2;
}
?>

1 + 1 = 3!?

Wonky Code
More crazy code from my world. This is a pretty simple function, but WTF does 3 mean in the code?
  function checkAdminBrokersCorner($fran_id,$admin) {
    if (($admin >= 3) || ($fran_id == 208)) {
      return true;
    }
    return false;
  }
The $fran_id == 208 is fairly easy to figure out. It likely refers to a database ID number. However $admin >= 3 is a little harder to determine what it means.
XML feed