[TYPO3-core] RFC #9266: Bug: strcmp() with array as parameter in t3lib_div::linkThisScript() produces warnings with PHP 5.3

Niels Pardon mail at niels-pardon.de
Wed Oct 1 20:38:03 CEST 2008


Hi Benni,

just recognized that you wrote a comment.

Benjamin Mack schrieb:
>> yes, that's true. But what if the $value = 0? Then empty($value) will be
>> true and I'm not sure whether this intended.
> Yes, but in your current one, you have a !== '' and then $value = 0
> wouldn't work either, right?

The point is the following:

if $v == '' then strcmp($v,'') == 0 which is equal to FALSE
if $v != '' then strcmp($v,'') > 0 which is equal to TRUE

if $v == 0 then strcmp($v,'') > 0 which is equal to TRUE
BUT: if $v == 0 then !empty($v) == FALSE

So the equivalent by not using strcmp() would be:

if ($v !== '') {
	...
} else {
	unset();
}

Or the other way round:

if ($v == '') {
	unset();
} else {
	...
}

So my version is closer to the original with strcmp().

Greets,

Niels


More information about the TYPO3-team-core mailing list