From 9737e4b259e5673b055d4c8316d4c9e2892f984b Mon Sep 17 00:00:00 2001 From: Christoph Michael Becker Date: Mon, 23 Nov 2020 21:50:15 +0000 Subject: [PATCH] Added documentation for the str_starts_with and str_ends_with functions based on https://php.watch/versions/8.0/str_starts_with-str_ends_with Patch contributed by Emmanuel Okeke . git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@351549 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/strings/functions/str-contains.xml | 6 +- reference/strings/functions/str-ends-with.xml | 150 ++++++++++++++++++ .../strings/functions/str-starts-with.xml | 150 ++++++++++++++++++ reference/strings/functions/stripos.xml | 2 + reference/strings/functions/strpos.xml | 2 + reference/strings/versions.xml | 2 + 6 files changed, 310 insertions(+), 2 deletions(-) create mode 100644 reference/strings/functions/str-ends-with.xml create mode 100644 reference/strings/functions/str-starts-with.xml diff --git a/reference/strings/functions/str-contains.xml b/reference/strings/functions/str-contains.xml index 0bed156aa2..7ab3098b75 100644 --- a/reference/strings/functions/str-contains.xml +++ b/reference/strings/functions/str-contains.xml @@ -81,7 +81,7 @@ Checking the existence of the empty string will always return true $string = 'The lazy fox jumped over the fence'; if (str_contains($string, 'lazy')) { - echo "The string "lazy" was found in the string\n"; + echo "The string 'lazy' was found in the string\n"; } if (str_contains($string, 'Lazy')) { @@ -96,7 +96,7 @@ if (str_contains($string, 'Lazy')) { &example.outputs; @@ -113,6 +113,8 @@ The string "lazy" was found in the string &reftitle.seealso; + str_ends_with + str_starts_with stripos strrpos strripos diff --git a/reference/strings/functions/str-ends-with.xml b/reference/strings/functions/str-ends-with.xml new file mode 100644 index 0000000000..5008bb098d --- /dev/null +++ b/reference/strings/functions/str-ends-with.xml @@ -0,0 +1,150 @@ + + + + + str_ends_with + Checks if a string ends with a given substring + + + + &reftitle.description; + + boolstr_ends_with + stringhaystack + stringneedle + + + Performs a case-sensitive check indicating if + haystack ends with needle. + + + + + &reftitle.parameters; + + + + haystack + + + The string to search in. + + + + + needle + + + The substring to search for in the haystack. + + + + + + + + + &reftitle.returnvalues; + + Returns &true; if haystack ends with + needle, &false; otherwise. + + + + + &reftitle.examples; + + + Using the empty string <literal>''</literal> + + +]]> + + &example.outputs; + + + + + + + Showing case-sensitivity + + +]]> + + &example.outputs; + + + + + + + + + &reftitle.notes; + ¬e.bin-safe; + + + + &reftitle.seealso; + + + str_contains + str_starts_with + stripos + strrpos + strripos + strstr + strpbrk + substr + preg_match + + + + + + + diff --git a/reference/strings/functions/str-starts-with.xml b/reference/strings/functions/str-starts-with.xml new file mode 100644 index 0000000000..fe84cc2c77 --- /dev/null +++ b/reference/strings/functions/str-starts-with.xml @@ -0,0 +1,150 @@ + + + + + str_starts_with + Checks if a string starts with a given substring + + + + &reftitle.description; + + boolstr_starts_with + stringhaystack + stringneedle + + + Performs a case-sensitive check indicating if + haystack begins with needle. + + + + + &reftitle.parameters; + + + + haystack + + + The string to search in. + + + + + needle + + + The substring to search for in the haystack. + + + + + + + + + &reftitle.returnvalues; + + Returns &true; if haystack begins with + needle, &false; otherwise. + + + + + &reftitle.examples; + + + Using the empty string <literal>''</literal> + + +]]> + + &example.outputs; + + + + + + + Showing case-sensitivity + + +]]> + + &example.outputs; + + + + + + + + + &reftitle.notes; + ¬e.bin-safe; + + + + &reftitle.seealso; + + + str_contains + str_ends_with + stripos + strrpos + strripos + strstr + strpbrk + substr + preg_match + + + + + + + diff --git a/reference/strings/functions/stripos.xml b/reference/strings/functions/stripos.xml index 3748ffda63..6e5193c37d 100644 --- a/reference/strings/functions/stripos.xml +++ b/reference/strings/functions/stripos.xml @@ -144,6 +144,8 @@ if ($pos2 !== false) { mb_stripos str_contains + str_ends_with + str_starts_with strpos strrpos strripos diff --git a/reference/strings/functions/strpos.xml b/reference/strings/functions/strpos.xml index 3fd328ab29..9aa94c5a22 100644 --- a/reference/strings/functions/strpos.xml +++ b/reference/strings/functions/strpos.xml @@ -167,6 +167,8 @@ $pos = strpos($newstring, 'a', 1); // $pos = 7, not 0 stripos str_contains + str_ends_with + str_starts_with strrpos strripos strstr diff --git a/reference/strings/versions.xml b/reference/strings/versions.xml index 21445f0788..d04b0b7896 100644 --- a/reference/strings/versions.xml +++ b/reference/strings/versions.xml @@ -56,6 +56,7 @@ + @@ -64,6 +65,7 @@ +