rfc:add_str_begin_and_end_functions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:add_str_begin_and_end_functions [2019/07/05 08:32] – Use new function names in RFC title nikic | rfc:add_str_begin_and_end_functions [2019/07/22 08:47] (current) – Close voting nikic | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PHP RFC: Add str_starts_withs(), str_ends_with() and related functions ====== | + | ====== PHP RFC: Add str_starts_with(), str_ends_with() and related functions ====== |
* Version: 0.4 | * Version: 0.4 | ||
* Date: 2016-08-01 (use today' | * Date: 2016-08-01 (use today' | ||
* Author: Will Hudgins, will@wkhudgins.info | * Author: Will Hudgins, will@wkhudgins.info | ||
- | * Status: | + | * Status: |
* First Published at: https:// | * First Published at: https:// | ||
Line 10: | Line 10: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | Add str_starts_with(), | + | Add str_starts_with(), |
- | boolean | + | < |
- | | + | function |
- | | + | function |
- | | + | function |
- | | + | function |
- | | + | function |
- | | + | function |
- | | + | function |
+ | function | ||
+ | </ | ||
| | ||
str_starts_with() checks if $haystack begins with $needle. It accomplishes this by comparing each character in $haystack with the corresponding character in $needle. If any of the characters do not match, it will return false. str_ends_with() does the same thing except in reverse: it starts at the end of both $haystack and $needle and compares each character in $haystack to the corresponding character in $needle. | str_starts_with() checks if $haystack begins with $needle. It accomplishes this by comparing each character in $haystack with the corresponding character in $needle. If any of the characters do not match, it will return false. str_ends_with() does the same thing except in reverse: it starts at the end of both $haystack and $needle and compares each character in $haystack to the corresponding character in $needle. | ||
Line 28: | Line 30: | ||
Examples below: | Examples below: | ||
- | | + | |
- | if (str_starts_with($str, | + | < |
- | echo "This condition would be true"; | + | $str = " |
- | | + | if (str_starts_with($str, |
- | | + | echo "This condition would be true"; |
- | | + | if (str_starts_with($str, |
- | | + | echo "This condition would not be true"; |
- | | + | if (str_starts_with_ci($str, |
- | | + | echo "This condition would be true"; |
- | | + | if (str_starts_with_ci($str, |
- | echo "This condition would be true"; | + | echo "This condition would also be true"; |
- | | + | if (str_ends_with($str, |
- | | + | echo "This condition would be true"; |
- | | + | if (str_ends_with($str, |
- | | + | echo "This condition would not be true"; |
- | | + | if (str_ends_with_ci($str, |
- | | + | echo "This condition would be true"; |
+ | if (str_ends_with_ci($str, | ||
+ | echo "This condition would also be true"; | ||
+ | </ | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 84: | Line 89: | ||
< | < | ||
- | title=" | + | title=" |
* yes | * yes | ||
* no | * no | ||
Line 92: | Line 97: | ||
< | < | ||
- | title=" | + | title=" |
* yes | * yes | ||
* no | * no |
rfc/add_str_begin_and_end_functions.txt · Last modified: 2019/07/22 08:47 by nikic