ID: 41375 Updated by: [EMAIL PROTECTED] Reported By: bugs dot php dot net at kreidenweis dot com Status: Open Bug Type: Documentation problem Operating System: Any PHP Version: 5.2.2 New Comment:
Alright, here's the use case: I have a string. I want at most 16 characters of it. For all PHP versions before 5.2.[2 or 3], I could do this: $shorter = substr($string, -16); Now I have to do this: if (strlen($string) > 16)) $shorter = substr($string, -16); else $shorter = $string; My question is, especially since I'm asking that the historical behavior of PHP be maintained, how does this change improve the language? What is the point of it? Previous Comments: ------------------------------------------------------------------------ [2007-09-07 15:36:40] [EMAIL PROTECTED] I don't think it's good idea to change it in every release back and forth. Also the current behavior makes much more sense to me. Negative string length is a nonsense, so false is the correct result. ------------------------------------------------------------------------ [2007-09-07 15:12:40] [EMAIL PROTECTED] Yes, of course it should have been caught in the RC stage, but it wasn't - in fact it took me more than one final release to track it down. Why is what's done, done, when the behavior that was changed existed for years and years, and the new behavior has been around for 2 point releases? ------------------------------------------------------------------------ [2007-09-07 14:59:08] [EMAIL PROTECTED] Don't you think such questions should have been asked during RC stage? It's a bit too late to change it back, what's done is done. ------------------------------------------------------------------------ [2007-09-07 14:46:42] [EMAIL PROTECTED] Okay, documenting it at least makes code and documentation consistent, but why the change in the first place? Why not avoid the break and leave it consistent? ------------------------------------------------------------------------ [2007-09-07 09:40:38] [EMAIL PROTECTED] Reclassified. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/41375 -- Edit this bug report at http://bugs.php.net/?id=41375&edit=1