EllisLab text mark
Advanced Search
1 of 2
1
   
CI made me laugh
Posted: 11 June 2010 05:34 AM   [ Ignore ]
Avatar
Joined: 2009-10-08
9 posts
/**
* Is Numeric
*
* @access    public
* @param    string
* @return    bool
*/

function is_numeric($str)
{
    
return ( ! is_numeric($str)) ? FALSE TRUE;

 
Posted: 11 June 2010 07:37 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2008-06-25
133 posts

That’s one clever piece of code! wink

 Signature 

Blog | Twitter | Last.fm
MY_Form_Validation - extended for protection using nonce words

 
Posted: 11 June 2010 09:39 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2006-12-04
515 posts

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

 Signature 

————————
Eric Barnes | Twitter
————————

 
Posted: 01 July 2010 07:20 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2010-07-01
1 posts

Whats funny with it???I don’t figure it out….Maybe I’m just some kind a stupid…lol

 Signature 

Lutz105

 
Posted: 01 July 2010 10:41 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2009-12-08
1804 posts

It’s redundant, it serves no purpose.

 Signature 

@basdflasjk | BitAuth: Authentication and Role-based Permissions | Session Library Replacement


Please read the User Guide! (Upgrading from a previous version?)

 
Posted: 02 July 2010 07:16 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2008-03-28
430 posts
Lutz105 - 01 July 2010 11:20 AM

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! smile

 Signature 

———————————————————————————————————————————-
Imac 27” Core i7 / 12GB RAM
Macbook Pro 15” C2D 2.53Ghz / 4GB RAM / NVIDIA GeForce 9400M + 9600M GT 512MB
iPhone 4 16Gb Black

http://www.rockkarusellen.se

 
Posted: 02 July 2010 08:13 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2007-02-06
743 posts
Johan André - 02 July 2010 11:16 PM
Lutz105 - 01 July 2010 11:20 AM

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! smile

Not only that, the method could have been written more simply like this:

function is_numeric($str)
{
    
return is_numeric($str);
 Signature 

“I am the terror that flaps in the night”

 
Posted: 03 July 2010 05:32 AM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4404 posts

Have you tried calling that? And what happened?

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 03 July 2010 11:33 AM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-11
166 posts

why not just use the php ‘is_numeric’? why use the helper when the native php is already there?

 
Posted: 04 August 2010 05:58 PM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Joined: 2010-04-27
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;

smile

 
Posted: 08 August 2010 09:34 AM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2010-08-08
304 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.

 Signature 

Plenty Parser - Parser library WolfAuth - Role Based Authentication library | CI Smarty - Smarty integration for Codeigniter 2.0+ | CI Plugins System - A simple hooks system.

 
Posted: 20 August 2010 11:03 AM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2009-08-23
34 posts

Haaaaaax. Leet skills at camp CI wink

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 smile

 Signature 

“To the user, the interface is the system”

Fivetwelve - Web design, development & consultancy, based in Mid-Wales

Twitter - Follow me @512uk

ftw.gd - The l33t URL shortener from Fivetwelve

 
Posted: 01 December 2010 04:47 PM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Avatar
Joined: 2009-01-21
51 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.

 Signature 

Web Applications Developer | http://jrtashjian.com | Twitter

 
Posted: 02 December 2010 10:31 PM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Avatar
Joined: 2009-04-13
369 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.

 Signature 

Blog | UhOh! | Formation | Query Strings in CI

 
Posted: 08 December 2010 03:52 PM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Joined: 2009-02-03
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.

 
Posted: 12 December 2010 09:22 AM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Joined: 2010-12-12
2 posts

This joke is so nerdy ;D

 Signature 

http://www.translation-of-contracts.co.uk/

 
1 of 2
1