List of PHP binary safe functions: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
| (6 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
List of PHP '''binary safe'''<ref>[https://en.wikipedia.org/wiki/Binary-safe Binary-safe - Wikipedia]</ref> functions. Briefly speaking, using binary safe functions to | List of PHP '''binary safe'''<ref>[https://en.wikipedia.org/wiki/Binary-safe Binary-safe - Wikipedia]</ref> functions. Briefly speaking, using binary safe functions to manipulate the string in Mandarin or other unicode string. | ||
{| class="wikitable sortable" | {| class="wikitable sortable" | ||
| Line 8: | Line 8: | ||
|- | |- | ||
| "Get string length" || [https://www.php.net/manual/en/function.mb-strlen.php mb_strlen] || [https://www.php.net/manual/en/function.strlen.php strlen] | | "Get string length" || [https://www.php.net/manual/en/function.mb-strlen.php mb_strlen] || [https://www.php.net/manual/en/function.strlen.php strlen] | ||
|- | |||
| "Convert a string to an array || [https://www.php.net/manual/en/function.mb-str-split.php mb_str_split] || [https://www.php.net/manual/en/function.str-split.php str_split] | |||
|- | |- | ||
| "Count the number of substring occurrences" || [https://www.php.net/manual/en/function.mb-substr-count.php mb_substr_count] || [https://www.php.net/substr-count substr_count] | | "Count the number of substring occurrences" || [https://www.php.net/manual/en/function.mb-substr-count.php mb_substr_count] || [https://www.php.net/substr-count substr_count] | ||
| Line 13: | Line 15: | ||
| "Replace all occurrences of the search string with the replacement string" || [https://www.php.net/manual/en/function.str-replace.php str_replace] || | | "Replace all occurrences of the search string with the replacement string" || [https://www.php.net/manual/en/function.str-replace.php str_replace] || | ||
|- | |- | ||
| "Find the position of the first occurrence of a substring in a string" || [https://php.net/manual/en/function.strpos.php | | "Find the position of the first occurrence of a substring in a string" || [https://www.php.net/manual/en/function.mb-strpos.php mb_strpos] || [https://php.net/manual/en/function.strpos.php strpos] | ||
|- | |- | ||
| "Replace text within a portion of a string" || [https://www.php.net/manual/en/function.substr-replace.php substr_replace] || | | "Replace text within a portion of a string" || [https://www.php.net/manual/en/function.substr-replace.php substr_replace] or [https://gist.github.com/JBlond/942f17f629f22e810fe3 mb_substr_replace] || | ||
|- | |- | ||
| ... || ... || ... | | ... || ... || ... | ||
| Line 21: | Line 23: | ||
== | == References == | ||
<references /> | <references /> | ||
[[Category:PHP]] [[Category:Programming]] | [[Category:PHP]] [[Category:Programming]] | ||
[[Category:Web_Dev]] | [[Category:Web_Dev]] | ||
Latest revision as of 23:30, 1 February 2024
List of PHP binary safe[1] functions. Briefly speaking, using binary safe functions to manipulate the string in Mandarin or other unicode string.
| Purpose | Binary safe function | NOT binary safe |
|---|---|---|
| "Return part of a string" | mb_substr | substr |
| "Get string length" | mb_strlen | strlen |
| "Convert a string to an array | mb_str_split | str_split |
| "Count the number of substring occurrences" | mb_substr_count | substr_count |
| "Replace all occurrences of the search string with the replacement string" | str_replace | |
| "Find the position of the first occurrence of a substring in a string" | mb_strpos | strpos |
| "Replace text within a portion of a string" | substr_replace or mb_substr_replace | |
| ... | ... | ... |