/**
* Is Numeric
*
* @access public
* @param string
* @return bool
*/
function is_numeric($str)
{
return ( ! is_numeric($str)) ? FALSE : TRUE;
}This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
June 11, 2010 5:34am
Subscribe [16]#1 / Jun 11, 2010 5:34am
/**
* Is Numeric
*
* @access public
* @param string
* @return bool
*/
function is_numeric($str)
{
return ( ! is_numeric($str)) ? FALSE : TRUE;
}#2 / Jun 11, 2010 7:37am
That’s one clever piece of code! 😉
#3 / Jun 11, 2010 9:39am
That is awesome. Hopefully one day I will them skillz.
#4 / Jul 01, 2010 7:20am
Whats funny with it???I don’t figure it out….Maybe I’m just some kind a stupid…lol
#5 / Jul 01, 2010 10:41am
It’s redundant, it serves no purpose.
#6 / Jul 02, 2010 7:16pm
Whats funny with it???I don’t figure it out….Maybe I’m just some kind a stupid…lol
The funny thing is (assuming it’s found in the form validation library) that it’s longer to write $this->is_numeric($val) than is_numeric($val). And the purpose of the method is probably not going to change (either it returns false on non-numeric values or true on numeric ones).
Somewhat “geeky” to notice but still funny! 😊
#7 / Jul 02, 2010 8:13pm
Whats funny with it???I don’t figure it out….Maybe I’m just some kind a stupid…lol
The funny thing is (assuming it’s found in the form validation library) that it’s longer to write $this->is_numeric($val) than is_numeric($val). And the purpose of the method is probably not going to change (either it returns false on non-numeric values or true on numeric ones).
Somewhat “geeky” to notice but still funny! 😊
Not only that, the method could have been written more simply like this:
function is_numeric($str)
{
return is_numeric($str);
}#8 / Jul 03, 2010 5:32am
Have you tried calling that? And what happened?
#9 / Jul 03, 2010 11:33am
why not just use the php ‘is_numeric’? why use the helper when the native php is already there?
#10 / Aug 04, 2010 5:58pm
Sorry to bump an oldish post, but this thread reminded me of some funny code I saw on another site…
public boolean isBooleanFalse(boolean value) {
boolean response = false;
if (value == true) {
response = false;
} else {
response = true;
}
return response;
}😊
#11 / Aug 08, 2010 9:34am
You know you’re a nerd when you see things like that and find them funny. Needless to say, I laughed when I read that. Haha.
#12 / Aug 20, 2010 11:03am
Haaaaaax. Leet skills at camp CI 😉
I can see why they’d do this though. Just to keep everything kinda “uniform” I guess, rather than having some functions prefixed with a class call like $this->is_alpha_numeric() and others that are calls just to native PHP like is_numeric().
Personally I’d do what they did and just keep everything uniform, otherwise it can be confusing for the user deciding which ones to use.
Awesome find though 😊
#13 / Dec 01, 2010 3:47pm
I believe this snippet is rogue code. It’s not being used anywhere and in fact, the PHP built-in function is_numeric() gets called all over the place.
#14 / Dec 02, 2010 9:31pm
This is for the Form Validation library. All rules are basically just callbacks. So the is_numeric function is required in order to have the is_numeric validation rule. It’s not that big of deal.
#15 / Dec 08, 2010 2:52pm
Dan,
Form Validation already suport native php methods that accepts one parameter, so it still makes no sense =)
Any native PHP function that accepts one parameter can be used as a rule, like htmlspecialchars, trim, MD5, etc.