[TYPO3-core] RFC: Bug #6114: t3lib_extMgm::addToAllTCATypes ignores type 0
Dmitry Dulepov [typo3]
dmitry at typo3.org
Tue Dec 4 22:13:51 CET 2007
Hi!
Ingmar Schlecht wrote:
> Yet this line doesn't look right to me:
>
> if ($specificTypesList == '' || ...
>
> Wouldn't that eval to true for $specificTypesList = 0 as well? Maybe not
> for the string $specificTypesList = '0', but still for the integer.
There are two different cases here depending on variable type.
If $a == '0', than $a == '' is false (because string '0' is not equal to string '').
If $a == 0, than $a == '' evaluates to true (because values of different types are converted to values of a single common type before comparison, here to integer 0 and then 0 equals 0)
Safest and fastest way here is $a === '' (notice three equals!) because uses language construct (not a function call). To be paranoically safest: trim($a) === '' but this is an overkill I think :)
--
Dmitry Dulepov
TYPO3 core team
Web: http://typo3bloke.net/
Skype: callto:liels_bugs
"Nothing is impossible. There are only limits to our knowledge"
More information about the TYPO3-team-core
mailing list