Re: Odd is_int() behaviour

From: Date: Mon, 22 Oct 2001 05:54:35 +0000
Subject: Re: Odd is_int() behaviour
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-71788@lists.php.net to get a copy of this message
This is expected behaviour. Ashley M. Kirchner wrote:
    I have the following snippet in my file:
      if ($PATH_INFO == "") { $PATH_INFO = "/"; }
      echo "PATH_INFO: $PATH_INFO<br>\n";
      // All we want is the fist element, call it $section
      list($section) = explode('/', substr($PATH_INFO,1));
explode() is string function and returns array of strings. Therefore, type is integer.
      if (is_int($section)) {
        echo "section: $section<br>\n";
      } else {
        echo "Invalid section (NON_INT: $section)<br>\n";
      }
    Um, why does it fail when I hit the script with any INT?
'1' is not integer, but string. 1 is integer. BTW, all user inputs(POST/GET/etc) are string. -- Yasuo Ohgaki

« previous php.general (#71788) next »