Re: Changed behaviour for strtr()
| From: | Jordi Boggiano | Date: | Wed, 22 Jun 2011 00:14:06 +0000 |
| Subject: | Re: Changed behaviour for strtr() | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-53497@lists.php.net to get a copy of this message | ||
On Tue, Jun 21, 2011 at 12:55 PM, Derick Rethans <derick@php.net> wrote:
> On Mon, 20 Jun 2011, Stas Malyshev wrote:
>
>> > Here is the next one.
>> >
>> > I think it's quite intuitive to use strtr() to remove single characters of a
>> > string, too, instead of using many str_replace($str, $chr, ""). I'd
>> > glad to
>> > see this change also in 5.4.
>>
>> This is a BC break, if I understand it correctly, so I don't think it is a
>> good idea.
>
> I agree that this is not a good thing then.
Right now strtr('anything', 'anything', '') === 'anything',
which
means that anyone relying on this behavior is doing something strange
and dumb imo, doing a function call for nothing. We could maybe say
that strtr('anything', 'anything', null) maps all letters to an empty
string? That should take care of the user-based inputs for BC reasons,
while still allowing strtr() to be used for this "strip letter x and
y" use case.
Anyway I'm not gonna fight one way or the other, it's a detail, but I
don't think the BC concern is as big as it's presented.
Cheers
--
Jordi Boggiano
@seldaek :: http://seld.be/