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

Martin Kutschker Martin.Kutschker at n0spam-blackbox.net
Wed Sep 5 10:54:26 CEST 2007


Ingmar Schlecht schrieb:
> 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.

But isn't that the point? You compare strings and not integers. If you get 
an integer somethig is wrong.

Masi


More information about the TYPO3-team-core mailing list