rfc:add_str_starts_with_and_ends_with_functions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:add_str_starts_with_and_ends_with_functions [2020/04/05 15:56] – typo guilliamxavier | rfc:add_str_starts_with_and_ends_with_functions [2020/05/05 14:12] (current) – nikic | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Add str_starts_with() and str_ends_with() functions ====== | ====== PHP RFC: Add str_starts_with() and str_ends_with() functions ====== | ||
* Version: 0.5 | * Version: 0.5 | ||
- | * Date: 2020-03-25 (**Updated**: | + | * Date: 2020-03-25 (**Updated**: |
* Author: Will Hudgins, will@wkhudgins.info | * Author: Will Hudgins, will@wkhudgins.info | ||
- | * Status: | + | * Status: |
* First Published at: https:// | * First Published at: https:// | ||
Line 14: | Line 14: | ||
The '' | The '' | ||
- | Checking the start and end of strings is a very common task which should be easy. Accomplishing this task is not easy now and that is why many frameworks have chosen to include it. This is also why other high-level programming languages---diverse as JavaScript, Java, Haskell, and Matlab---have implemented this functionality. Checking the start and end of a string should not be a task which requires pulling in a PHP framework or developing a potentially suboptimal (or worse, buggy) function in userland. | + | Checking the start and end of strings is a very common task which should be easy. Accomplishing this task is not easy now and that is why many frameworks have chosen to include it. This is also why other high-level programming languages---as diverse as JavaScript, Java, Haskell, and Matlab---have implemented this functionality. Checking the start and end of a string should not be a task which requires pulling in a PHP framework or developing a potentially suboptimal (or worse, buggy) function in userland. |
==== Downsides of Common Userland Approaches ===== | ==== Downsides of Common Userland Approaches ===== | ||
- | Ad hoc userland implementations of this functionality are //less intuitive// | + | Ad hoc userland implementations of this functionality are __less intuitive__ |
- | The implementation is also // | + | The implementation is also __easy |
- | Additionally, | + | Additionally, |
- | Note: the examples below are sometimes additionally guarded by "< | + | //Note: some implementations add "//< |
=== str_starts_with === | === str_starts_with === | ||
Line 49: | Line 49: | ||
strpos(strrev($haystack), | strpos(strrev($haystack), | ||
</ | </ | ||
- | This is CPU inefficient because it requires reversing both the haystack and the needle as well as applying '' | + | This is doubly |
<PHP> | <PHP> | ||
Line 105: | Line 105: | ||
* **New Constants: | * **New Constants: | ||
* **php.ini Defaults:** No changed php.ini settings. | * **php.ini Defaults:** No changed php.ini settings. | ||
+ | |||
+ | ===== Votes ===== | ||
+ | Voting closes 2020-05-04 | ||
+ | |||
+ | < | ||
+ | title=" | ||
+ | * yes | ||
+ | * no | ||
+ | </ | ||
+ | |||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
Line 132: | Line 142: | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
- | * Case-insensitive and multibyte variants were included in the previous version of this RFC, which was declined. See also [[rfc: | + | |
rfc/add_str_starts_with_and_ends_with_functions.1586102203.txt.gz · Last modified: 2020/04/05 15:56 by guilliamxavier