Re: [PATCH] substr() returns false

From: Date: Thu, 20 Nov 2003 10:03:06 +0000
Subject: Re: [PATCH] substr() returns false
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-5609@lists.php.net to get a copy of this message
On Wed, 2003-11-19 at 19:30, Andi Gutmans wrote: > Isn't it a mistake to give a start position at the end or beyond the > string? You could easily argue, that beyond the end is an error, but I agree with the way Perl allows the start to be at the end. I think of it as with (pseudo-) C: char str[] = { 'A', 'B', '\0' }; substr(str, 0) == "AB" substr(str, 2) == "" substr(str, 3) ERROR > In this case, doesn't it make sense to return false? If things doesn't make sense, I think there should be some kind of warning too (like with array to string cast). On Wed, 2003-11-19 at 22:30, Jani Taskinen wrote: > IF you change it, it'll break BC.. :) True, but if you do it like Perl, it will only break BC for the case where start is at the end of string, which is an error now. > IMO, it should just give an error in such case, and return FALSE too. Yes, with the case where start is beyond the end (which is an error), there should be a warning or an error. Morten -- Morten Poulsen <morten-Qg2caEh8@afdelingp.dk> http://www.afdelingp.dk/

« previous php.internals (#5609) next »