[TYPO3-core] RFC: Fix bug #1391: Typo3 can't display a single "0" in a table cell

Michael Stucki michael at typo3.org
Tue Feb 28 20:06:45 CET 2006


Hi René,

>> Michael Stucki wrote:
>> > The solution is to add a new property which compares the value using
>> > strcmp('',$value).
>>
>> Don't use strcmp if you don't really want to compare the string. If you
>> want to test if it is set rather use strlen($str).
> 
> Could we then change all the ugly occurencies of strcmp() in the code base
> to strlen()?! Kasper had a reason for that but if strlen() do the same I
> prefer that.

See Coding Guidelines:

| In comparing strings, use strcmp() (returns false if strings matches!),
| prefix supposed string variables with '(string)' or use ?===? if both
| values in the comparison should also have the same type.
| Reason: Consider this: $id==?my_string?. This will return true if 1) $id
| is a string, ?my_string? OR if 2) $id is an integer of zero in which case
| ?my_string? is converted to an integer - which will be zero! So instead do
| one of these: '(string)$id==?my_string?' or '!strcmp($id,?my_string?)'.
| The same with switch-constructs: 'switch((string)$id) {....'    

But that doesn't tell anything about empty strings. So I think Bernhard
could be right, and I will change the patch.

- michael
-- 
Use a newsreader! Check out
http://typo3.org/community/mailing-lists/use-a-news-reader/



More information about the TYPO3-team-core mailing list