Date: 06/29/01
- Next message: sintesi <email protected>: "[PHP-DEV] Bug #11801: crypt function not 'supported' ???"
- Previous message: diankov_ss <email protected>: "[PHP-DEV] Bug #11797: CC and BCC don't work in mail() function"
- In reply to: Derick Rethans: "[PHP-DEV] Re: [Zend Engine 2] substr changes"
- Reply: Derick Rethans: "[PHP-DEV] Re: [Zend Engine 2] substr changes"
- Maybe reply: Derick Rethans: "[PHP-DEV] Re: [Zend Engine 2] substr changes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> > Yes, of course. But in a loop when you use for ($i=-3; $i<=0; $i--)...
I've
> > had this twice, I needed to make special case for the last possibility.
>
> This works fine: $i will contain, -3, -2, -1 and 0 (and not -0), but
> indeed I agree that substr ('str', 0, 0) should return this: 'str'. This
> change can be easily made in the current sources. If nobody objects, I'll
> change it.
This is IMO 'van de regen in de drup', i.e. making it worse... The kind of
loop I mentioned isn't as current as a loop like this:
for ($i=5;$i>=0;$i--)
substr('abcdef',0,$i);
wich your proposed change, you get:
(i=5) abcde
4 abcd
3 abc
2 ab
1 a
0 abcdef !
This has to do with the fact that 0 ==== -0 (4 ='s, it's really identical),
and that you can loop to 0 in two ways, which have completely, incompatible
meaning.
I think that if it is changed, you'll break quite some scripts... the
problem isn't in the current implementation, it's in the idea behind letting
negative values have a special meaning.
By the way, IMO the negative values with substr rate higher on WTF than
{left,length[,right]}, though it may seem different because you're used to
substr().
> regards,
> Derick
Jeroen
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: sintesi <email protected>: "[PHP-DEV] Bug #11801: crypt function not 'supported' ???"
- Previous message: diankov_ss <email protected>: "[PHP-DEV] Bug #11797: CC and BCC don't work in mail() function"
- In reply to: Derick Rethans: "[PHP-DEV] Re: [Zend Engine 2] substr changes"
- Reply: Derick Rethans: "[PHP-DEV] Re: [Zend Engine 2] substr changes"
- Maybe reply: Derick Rethans: "[PHP-DEV] Re: [Zend Engine 2] substr changes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

