Is this an Int?

Sample function call:

if (!really_is_int($id)) {
  die('id is not integer Error 2438179. -Programmer.');

WARNING: The original version of function really_is_int fails to return the appropriate value when passed a zero (0). Zero is an integer as are all negative whole numbers.

Sample user defined function really_is_int:

function really_is_int($val)
  if(func_num_args() !== 1)
      exit(__FUNCTION__.'(): not passed 1 arg');

  $weirdPart = ((string)abs((int) $val));
  if ($weirdPart === "0") {
    return TRUE;

  return ($val !== true) && ((string)abs((int) $val)) === ((string) ltrim($val, '-0'));

I used the original version of this function in createA_kda_funcs.php.


About samehramzylabib

See About on
This entry was posted in PHP Data Value Types, PHP Form Processing and tagged , , , , . Bookmark the permalink.


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s