rfc:add_str_begin_and_end_functions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
rfc:add_str_begin_and_end_functions [2019/07/05 08:32] – Use new function names in RFC title nikicrfc:add_str_begin_and_end_functions [2019/07/09 01:19] – typo on function name gasolwu
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's date here) **Updated: 2019-06-18**   * Date: 2016-08-01 (use today's date here) **Updated: 2019-06-18**
Line 10: Line 10:
  
 ===== Proposal ===== ===== Proposal =====
-Add str_starts_with(), str_starts_with_ci(), str_ends_with(), str_ends_with_ci(), mb_str_starts_with(), mb_str_starts_with_ci(), mb_str_ends_with(), and mb_str_ends_with_ci() functions+Add str_starts_with(), str_starts_with_ci(), str_ends_with(), str_ends_with_ci(), mb_str_starts_with(), mb_str_starts_with_ci(), mb_str_ends_with(), and mb_str_ends_with_ci() functions:
  
-  boolean str_starts_with[(string $haystack, string $needle)] +<PHP> 
-  boolean str_starts_with_ci[(string $haystack, string $needle)] +function str_starts_with(string $haystack, string $needle): bool 
-  boolean str_ends_with[(string $haystack, string $needle)] +function str_starts_with_ci(string $haystack, string $needle): bool 
-  boolean str_ends_with_ci[(string $haystack, string $needle)] +function str_ends_with(string $haystack, string $needle): bool 
-  boolean mb_str_starts_with[(string $haystack, string $needle [, string $encoding])] +function str_ends_with_ci(string $haystack, string $needle): bool 
-  boolean mb_str_starts_with_ci[(string $haystack, string $needle [, string $encoding])] +function mb_str_starts_with(string $haystack, string $needle [, string $encoding]): bool 
-  boolean mb_str_ends_with[(string $haystack, string $needle [, string $encoding])] +function mb_str_starts_with_ci(string $haystack, string $needle [, string $encoding]): bool 
-  boolean mb_str_ends_with_ci[(string $haystack, string $needle [, string $encoding])]+function mb_str_ends_with(string $haystack, string $needle [, string $encoding]): bool 
 +function mb_str_ends_with_ci(string $haystack, string $needle [, string $encoding]): bool 
 +</PHP>
      
 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:
-  $str = "beginningMiddleEnd"; + 
-  if (str_starts_with($str, "beg")) +<PHP> 
-      echo "This condition would be true"; +$str = "beginningMiddleEnd"; 
-   if (str_starts_with($str, "Beg")) +if (str_starts_with($str, "beg")) 
-       echo "This condition would not be true"; +    echo "This condition would be true"; 
-   if (str_starts_with_ci($str, "beg")) +if (str_starts_with($str, "Beg")) 
-       echo "This condition would be true"; +    echo "This condition would not be true"; 
-   if (str_starts_with_ci($str, "Beg")) +if (str_starts_with_ci($str, "beg")) 
-       echo "This condition would also be true"; +    echo "This condition would be true"; 
-   if (str_ends_with($str, "End")) +if (str_starts_with_ci($str, "Beg")) 
-      echo "This condition would be true"; +    echo "This condition would also be true"; 
-   if (str_ends_with($str, "end")) +if (str_ends_with($str, "End")) 
-       echo "This condition would not be true"; +    echo "This condition would be true"; 
-   if (str_ends_with_ci($str, "End")) +if (str_ends_with($str, "end")) 
-       echo "This condition would be true"; +    echo "This condition would not be true"; 
-   if (str_ends_with_ci($str, "end")) +if (str_ends_with_ci($str, "End")) 
-       echo "This condition would also be true";+    echo "This condition would be true"; 
 +if (str_ends_with_ci($str, "end")) 
 +    echo "This condition would also be true"; 
 +</PHP>
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
Line 92: Line 97:
  
 <doodle  <doodle 
-title="Do you want mb_ str_starts_with, mb_str_starts_with_ci, mb_str_ends_with, and mb_str_ends_with_ci functions in PHP 7.4?" auth="user" voteType="single" closed="no">+title="Do you want mb_str_starts_with, mb_str_starts_with_ci, mb_str_ends_with, and mb_str_ends_with_ci functions in PHP 7.4?" auth="user" voteType="single" closed="no">
    * yes    * yes
    * no    * no
rfc/add_str_begin_and_end_functions.txt · Last modified: 2019/07/22 08:47 by nikic