ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

CI made me laugh

June 11, 2010 5:34am

Subscribe [16]
  • #1 / Jun 11, 2010 5:34am

    henlee

    6 posts

    /**
    * Is Numeric
    *
    * @access    public
    * @param    string
    * @return    bool
    */
    
    function is_numeric($str)
    {
        return ( ! is_numeric($str)) ? FALSE : TRUE;
    
    }
  • #2 / Jun 11, 2010 7:37am

    erik.brannstrom

    125 posts

    That’s one clever piece of code! 😉

  • #3 / Jun 11, 2010 9:39am

    Eric Barnes

    487 posts

    That is awesome.  Hopefully one day I will them skillz.

  • #4 / Jul 01, 2010 7:20am

    Lutz105

    1 posts

    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

    danmontgomery

    1802 posts

    It’s redundant, it serves no purpose.

  • #6 / Jul 02, 2010 7:16pm

    Johan André

    412 posts

    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

    Rick Jolly

    729 posts

    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

    WanWizard

    4475 posts

    Have you tried calling that? And what happened?

  • #9 / Jul 03, 2010 11:33am

    xeroblast

    154 posts

    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

    Stuey

    5 posts

    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

    Vheissu

    278 posts

    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

    georgeedwards

    29 posts

    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

    jrtashjian

    50 posts

    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

    Dan Horrigan

    342 posts

    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

    Eric Saboia

    6 posts

    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.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases