View Single Post
Old 09-08-2007, 12:15 AM   #3 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,347
Thanks: 5
Salathe is on a distinguished road
Default

It's a very simple function, but I'm going to be picky (it's late here and this is what I do when I'm tired).
  • Why do you create $szOutput? It is assigned a value and immediately the next line is the return.
  • Speaking of the return, why is $szOutput trimmed just before returning if the string is limited, but not in any other case?
  • This is my main gripe, the actual length of the returned value (if the string has been trimmed) is $iLength + strlen($szAffix). The returned string should be of length $iLength, not greater. What's the point of limiting to, say, 20 characters when the actual string returned is 23?
  • The function, as is, has a syntax error -- line 6, the last parenthesis shouldn't be there.
Salathe is offline  
Reply With Quote