[wp-trac] [WordPress Trac] #16974: absint to return 0 for values with non-numeric characters

WordPress Trac wp-trac at lists.automattic.com
Sat Mar 26 22:55:26 UTC 2011


#16974: absint to return 0 for values with non-numeric characters
--------------------------+----------------------
 Reporter:  sc0ttkclark   |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  General       |     Version:  3.1
 Severity:  minor         |  Resolution:  wontfix
 Keywords:  has-patch     |
--------------------------+----------------------

Comment (by sc0ttkclark):

 Was thinking more (one more try), perhaps absint could have an additional
 variable, so it'd be like:

 {{{
 function absint ($maybeint, $strict = false) {
     if ( $strict && ! is_numeric ( trim ( $maybeint ) ) ) {
         return 0;
     }
 }
 }}}

 This seems like a perfect solution, which wouldn't run the is_numeric /
 trim unless told to do so by the usage of absint($value,true);

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16974#comment:19>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list