avoid preg_match, use is_numeric
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 23 Jul 2006 12:14:49 +0000 (12:14 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 23 Jul 2006 12:14:49 +0000 (12:14 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@583 839d8a87-29fc-0310-9880-83ba4fa771e5

classes/Env.php

index 6a7b2ac..23ebd50 100644 (file)
@@ -66,7 +66,7 @@ class Env
     function i($key, $default = 0)
     {
         $i = Env::_get($key, $default);
-        return preg_match(',^[0-9]+$,', $i) ? intval($i) : $default;
+        return is_numeric($i) ? intval($i) : $default;
     }
 
     // }}}
@@ -120,7 +120,7 @@ class Post
     function i($key, $default = 0)
     {
         $i = Post::_get($key, $default);
-        return preg_match(',^[0-9]+$,', $i) ? intval($i) : $default;
+        return is_numeric($i) ? intval($i) : $default;
     }
 
     // }}}
@@ -173,7 +173,7 @@ class Get
     function i($key, $default = 0)
     {
         $i = Get::_get($key, $default);
-        return preg_match(',^[0-9]+$,', $i) ? intval($i) : $default;
+        return is_numeric($i) ? intval($i) : $default;
     }
 
     // }}}
@@ -226,7 +226,7 @@ class Cookie
     function i($key, $default = 0)
     {
         $i = Cookie::_get($key, $default);
-        return preg_match(',^[0-9]+$,', $i) ? intval($i) : $default;
+        return is_numeric($i) ? intval($i) : $default;
     }
 
     // }}}