[TYPO3-core] RFC: Feature #4064 - Navigation title in tree view

Ingmar Schlecht ingmar at typo3.org
Wed Sep 5 10:47:50 CEST 2007


Hi guys,

Ernesto Baschny [cron IT] schrieb:
> Martin Kutschker wrote: on 04.09.2007 20:39:
> 
>> BTW, how many ways do we use to test for an empty string?
>>
>> The code has this one:
>>
>> (strlen(trim($row['title'])) == 0)
>>
>> I prefer this:
>>
>> $var === ''
>>
>> but as trim returns a string trim($row['title'])=='' would be save.

Are you sure?

Wouldn't
	trim($row['title']) == ''
be true on $row['title']="0" ?

Anyway, trim($row['title']) === '' seems all fine.

>> Elsewhere we have this:
>>
>> strcmp($var,'')
> 
> 
> I have stumbled over the same question in my previous patch! I usually
> dislike strcmp because it is very unintuitive when reading. The "==="
> comparison is more my style and much easier to read. Is it slower? More
> error prone? If not, I would stick to that.

The problem with === for string comparisons is that
	123 === '123'
returns false, whereas
	!strcmp(123, '123')
returns true.

So there is a little difference between the two which sometimes makes it
handier to use strcmp.

cheers
Ingmar


-- 
Ingmar Schlecht
TYPO3 Association Active Member


More information about the TYPO3-team-core mailing list