Re: Proposal for a new basic function: str_contains
| From: | G. P. B. | Date: | Fri, 14 Feb 2020 10:14:13 +0000 |
| Subject: | Re: Proposal for a new basic function: str_contains | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108565@lists.php.net to get a copy of this message | ||
On Fri, 14 Feb 2020 at 10:58, Aegir Leet <aegir@aegir.sexy> wrote:
> I generally like the idea, but it seems many (most?) real-world
> implementations actually use mb_strpos() !== false by default.
>
>
>
> https://github.com/danielstjules/Stringy/blob/df24ab62d2d8213bbbe88cc36fc35a4503b4bd7e/src/Stringy.php#L206-L215
>
>
> https://github.com/illuminate/support/blob/6eff6cff19f7ad5540b9a61a9fb3612ca8218c19/Str.php#L157-L166
>
> So there should definitely be an mb_str_contains in ext/mbstring in
> addition to the regular str_contains proposed here.
>
The biggest reason to have an mb_* variant if for when comparing with case
insensitivity.
The only other reason is if you need to check a string which is in a
different encoding,
which is, I'm assuming, is a quasi non-existent problem as everything
things is UTF-8
nowadays.
The reason why I personally voted no on the previous RFC was that I don't
see the
value of having functions checking if a string starts/ends with a sequence
but not a
general one. Moreover, checking for a substring to start/end a string seems
to be
fitting for the current strpos functions.
This function on it's own is way more reasonable and useful to add IMHO
Best regards
George P. Banyard