# RFC Raised for str_starts_with and str_ends_with

- Thread: https://externals.io/message/109318
- Original archive: https://news-web.php.net/php.internals/109318
- Started by will@wkhudgins.info on 2020-03-26T02:35:50+00:00
- Messages: 5
- RFC: Add str_starts_with and str_ends_with to PHP (Implemented (PHP 8.0)) — https://externals.io/rfc/add_str_starts_with_and_ends_with_functions.md
- RFC: Add str_starts_with(), str_ends_with() and related functions (Declined) — https://externals.io/rfc/add_str_begin_and_end_functions.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #109318 — will@wkhudgins.info — 2020-03-26T02:35:50+00:00

URL: https://externals.io/message/109318#109318

Hi,

Hope everyone is doing alright. I just raised a new RFC 
(https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions , 
github patch: https://github.com/php/php-src/pull/5300) for adding 
str_starts_with and str_ends_with to PHP. I would like to open this RFC 
up to discussion.

I raised a similar RFC about 9 months ago 
(https://wiki.php.net/rfc/add_str_begin_and_end_functions) that was 
narrowly rejected. A major criticism of that RFC was the inclusion of 
case-insensitive versions of str_starts_with and str_ends_with. I have 
incorporated feedback from that experienced and narrowed the new RFC to 
only propose str_starts_with and str_ends_with.

Thanks,

Will

---

## #109325 — Nikita Popov — 2020-03-26T08:53:44+00:00

URL: https://externals.io/message/109318#109325 · In reply to: #109318

> Hi,
>
> Hope everyone is doing alright. I just raised a new RFC
> (https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions ,
> github patch: https://github.com/php/php-src/pull/5300) for adding
> str_starts_with and str_ends_with to PHP. I would like to open this RFC
> up to discussion.
>
> I raised a similar RFC about 9 months ago
> (https://wiki.php.net/rfc/add_str_begin_and_end_functions) that was
> narrowly rejected. A major criticism of that RFC was the inclusion of
> case-insensitive versions of str_starts_with and str_ends_with. I have
> incorporated feedback from that experienced and narrowed the new RFC to
> only propose str_starts_with and str_ends_with.
>

I was in favor of the previous RFC, so also in favor of this one :) These
are going to complement the recently added `str_contains()` nicely.

Notes on text:

> After that RFC was closed, a code freeze was in place for PHP8's release.
PHP8 has now been released and several individuals have requested the
str_starts_with and str_ends_with functionality again. This is a simple but
highly desired functionality for PHP.

I think you mean PHP 7.4 here. PHP 8.0 is not yet released, and not in
feature freeze either.

> Add str_starts_with, and str_starts_with_ci() functions

The second function should probably be `str_ends_with()` :)

Nikita

---

## #109326 — Guilliam Xavier — 2020-03-26T09:19:13+00:00

URL: https://externals.io/message/109318#109326 · In reply to: #109325

>
> 
>
> > […]
>
> I was in favor of the previous RFC, so also in favor of this one :) These
> are going to complement the recently added `str_contains()` nicely.
>
> Notes on text:
>
> > […]
> PHP8 has now been released and several individuals have requested the
> str_starts_with and str_ends_with functionality again. This is a simple but
> highly desired functionality for PHP.
>
> I think you mean PHP 7.4 here. PHP 8.0 is not yet released, and not in
> feature freeze either.
>
> > […]
>
> The second function should probably be `str_ends_with()` :)
>
> Nikita

Hi Will,

First, thank you for re-working on this, I would love to see it happen! :)

Nevertheless, apart from some typos (already reported), I still think
the RFC needs a "Motivation" section with actual examples of userland
implementations (using functions like
str[r]pos/strncmp/substr[_compare]... often with strlen, or even
preg_match/fnmatch... [with escaping]) and the downsides of each (e.g.
CPU-inefficient, memory-inefficient, error-prone, hard to
understand...) plus how they handle empty strings.

(And also probably shorten the introduction ^^ or move parts into a
new subsection)

PS: you could also add a link to the str_contains RFC

Best regards,

-- 
Guilliam Xavier

---

## #109543 — will@wkhudgins.info — 2020-04-06T02:23:52+00:00

URL: https://externals.io/message/109318#109543 · In reply to: #109326

> On Thu, Mar 26, 2020 at 9:54 AM Nikita Popov <nikita.ppv@gmail.com> 
> wrote:
> > […]
> 
> Hi Will,
> 
> First, thank you for re-working on this, I would love to see it happen! 
> :)
> 
> Nevertheless, apart from some typos (already reported), I still think
> the RFC needs a "Motivation" section with actual examples of userland
> implementations (using functions like
> str[r]pos/strncmp/substr[_compare]... often with strlen, or even
> preg_match/fnmatch... [with escaping]) and the downsides of each (e.g.
> CPU-inefficient, memory-inefficient, error-prone, hard to
> understand...) plus how they handle empty strings.
> 
> (And also probably shorten the introduction ^^ or move parts into a
> new subsection)
> 
> PS: you could also add a link to the str_contains RFC
> 
> Best regards,
Hello,

I have revised the RFC, 
https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions , 
based on feedback from Nikita and Guilliam (thank you).

Please review the revised RFC and share any feedback during the coming 
days.

Thank you,

Will

---

## #109700 — will@wkhudgins.info — 2020-04-17T21:34:49+00:00

URL: https://externals.io/message/109318#109700 · In reply to: #109543

> 
> > […]
> Hello,
> 
> I have revised the RFC,
> https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions ,
> based on feedback from Nikita and Guilliam (thank you).
> 
> Please review the revised RFC and share any feedback during the coming 
> days.
> 
> Thank you,
> 
> Will
I will be moving this RFC to a vote on Monday April 20, 2020. I will 
send out another email with the [VOTE] tag on that date when I update 
the RFC to include the voting macro.

Thanks,

Will
