IF you change it, it'll break BC.. :) IMO, it should just give an error in such case, and return FALSE too. --Jani
On Wed, 19 Nov 2003, Andi Gutmans wrote: >Not sure if/how this should be changed. >Isn't it a mistake to give a start position at the end or beyond the >string? In this case, doesn't it make sense to return false? > >Andi > >At 02:39 PM 11/19/2003 +0100, Morten Poulsen wrote: >>Hi, >> >>Even though this is documented, it is strange behaviour: If the from >>parameter to substr() is at, or past, the end of the input string, the >>function returns false. >> >>The function is documented as >>string substr ( string string, int start [, int length]) >> >>IMHO substr() should either >> >>1) be changed to do like Perl, which returns an error only if start is >>_beyond_ the end (not _at_): >>(from http://www.perldoc.com/perl5.6/pod/func/substr.html) >>my $null = substr $name, 6, 2; # returns '' (no warning) >>my $oops = substr $name, 7; # returns undef, with warning >> >>2) be changed to return an empty string, if start is either at or beyond >>the end of the input string. >> >>I have attached patches for both solutions. >> >>If you don't change it to be like Perl, I think it should be noted in >>the documentation (as with chop()). >>If, on the other hand, it _is_ changed to behave like Perl, I think it >>should be emphasized that you are not guaranteed that the result is a >>string, because this will cause (eg. has caused us) problems when using >>the result as part of the $data array to PEAR DB::execute(). >> >>Happy hacking, >>Morten >> >>-- >>Morten Poulsen <[EMAIL PROTECTED]> >>http://www.afdelingp.dk/ >> >> >>-- >>PHP Internals - PHP Runtime Development Mailing List >>To unsubscribe, visit: http://www.php.net/unsub.php > > -- https://www.paypal.com/xclick/[EMAIL PROTECTED]&no_note=1&tax=0¤cy_code=EUR -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php