[TYPO3-dev] behaviour of t3lib_div::testInt has been changed
Franz Holzinger
franz at ttproducts.de
Thu Sep 9 12:12:29 CEST 2010
Hello,
I have observed that the behaviour of the function t3lib_div::testInt
has been changed.
When I test a string '10.', then the result is TRUE, but it should be
FALSE. This is different to former versions of TYPO3, where
t3lib_div::testInt('10.') has returned FALSE.
PHP code to check this:
debug ($tmp = t3lib_div::testInt('10.'), 'test of
t3lib_div::testInt(\'10.\')');
$var = '10';
$tmp = ((string)intval($var) == $var);
debug ($tmp, 'a) (string)intval('.$var.') == '.$var);
$var = '10.';
$tmp = ((string)intval($var) == $var);
debug ($tmp, 'b) (string)intval('.$var.') == '.$var);
$var = '10';
$tmp = ((string)intval($var) === $var);
debug ($tmp, 'c) (string)intval('.$var.') === '.$var);
$var = '10.';
$tmp = ((string)intval($var) === $var);
debug ($tmp, 'd) (string)intval('.$var.') === '.$var);
/**
* Tests if the input can be interpreted as integer.
*
* @param mixed Any input variable to test
* @return boolean Returns true if string is an integer
*/
public static function testInt($var) {
return (string)intval($var) == $var;
}
This should be:
/**
* Tests if the input can be interpreted as integer.
*
* @param mixed Any input variable to test
* @return boolean Returns true if string is an integer
*/
public static function testInt($var) {
return (string)intval($var) === $var;
}
Is this change intended?
If yes, then some TYPO3 extensions need modifications for TYPO3 4.5.
There has been a change:
http://forge.typo3.org/projects/typo3v4-core/repository/revisions/8586/diff
- Franz
More information about the TYPO3-dev
mailing list