Skip to main content
replaced http://de2.php.net with https://www.php.net
Source Link

You should use ctype_digit for that:

function integer($str) { return ctype_digit($str) ? $str : false; } 

Or use filter_var with FILTER_VALIDATE_INTFILTER_VALIDATE_INT:

function integer($str) { return filter_var($str, FILTER_VALIDATE_INT, array( 'options' => array('min_range' => 0), 'flags' => FILTER_FLAG_ALLOW_OCTAL )); } 

You should use ctype_digit for that:

function integer($str) { return ctype_digit($str) ? $str : false; } 

Or use filter_var with FILTER_VALIDATE_INT:

function integer($str) { return filter_var($str, FILTER_VALIDATE_INT, array( 'options' => array('min_range' => 0), 'flags' => FILTER_FLAG_ALLOW_OCTAL )); } 

You should use ctype_digit for that:

function integer($str) { return ctype_digit($str) ? $str : false; } 

Or use filter_var with FILTER_VALIDATE_INT:

function integer($str) { return filter_var($str, FILTER_VALIDATE_INT, array( 'options' => array('min_range' => 0), 'flags' => FILTER_FLAG_ALLOW_OCTAL )); } 
deleted 5 characters in body
Source Link
NikiC
  • 102.2k
  • 39
  • 194
  • 226

You should use ctype_digit for that:

function integer($str) { return ctype_digit($str) ? $str : false; } 

Or just use filter_var with FILTER_VALIDATE_INT:

function integer($str) { return filter_var($str, FILTER_VALIDATE_INT, array( 'options' => array('min_range' => 0), 'flags' => FILTER_FLAG_ALLOW_OCTAL )); } 

You should use ctype_digit for that:

function integer($str) { return ctype_digit($str) ? $str : false; } 

Or just use filter_var with FILTER_VALIDATE_INT:

function integer($str) { return filter_var($str, FILTER_VALIDATE_INT, array( 'options' => array('min_range' => 0), 'flags' => FILTER_FLAG_ALLOW_OCTAL )); } 

You should use ctype_digit for that:

function integer($str) { return ctype_digit($str) ? $str : false; } 

Or use filter_var with FILTER_VALIDATE_INT:

function integer($str) { return filter_var($str, FILTER_VALIDATE_INT, array( 'options' => array('min_range' => 0), 'flags' => FILTER_FLAG_ALLOW_OCTAL )); } 
added 'flags' => FILTER_FLAG_ALLOW_OCTAL
Source Link
Gordon
  • 317.8k
  • 76
  • 548
  • 566

You should use ctype_digit for that:

function integer($str) { return ctype_digit($str) ? $str : false; } 

Or just use filter_var with FILTER_VALIDATE_INT:

function integer($str) { return filter_var($str, FILTER_VALIDATE_INT, array( 'options' => array('min_range' => 0), 'flags' => FILTER_FLAG_ALLOW_OCTAL )); } 

You should use ctype_digit for that:

function integer($str) { return ctype_digit($str) ? $str : false; } 

Or just use filter_var with FILTER_VALIDATE_INT:

function integer($str) { return filter_var($str, FILTER_VALIDATE_INT, array( 'options' => array('min_range' => 0) )); } 

You should use ctype_digit for that:

function integer($str) { return ctype_digit($str) ? $str : false; } 

Or just use filter_var with FILTER_VALIDATE_INT:

function integer($str) { return filter_var($str, FILTER_VALIDATE_INT, array( 'options' => array('min_range' => 0), 'flags' => FILTER_FLAG_ALLOW_OCTAL )); } 
updated filter_var with check for min range
Source Link
Gordon
  • 317.8k
  • 76
  • 548
  • 566
Loading
Source Link
NikiC
  • 102.2k
  • 39
  • 194
  • 226
Loading