of the variable $string
${string%%substring}
Delete the substring of the longest matching $substring from the end of the variable $string
${string/substring/replacement}
Use $replacement to replace the first matching $substring
${
}
Use $replacement to replace the first matching $substring
${string//substring/replacement}
Use $replacement instead of all matching $substring
${string/#substring/replacement}
If the $string prefix matches the $substring, then the $replacement is used instead of the matching $substring
${
}
Use $replacement to replace all matching $substring
${string/#substring/replacement}
If the $string prefix matches the $substring, the $replacement is used instead of the matching $substring
${string/%substring/replacement}
If the $string suffix matches the $substring, then the $re
${string//substring/replacement}
Use $replacement instead of all matching $substring
${string/#substring/replacement}
If the $string prefix matches the $substring, then the $replacement is used instead of the matching $substring
${string/%substr
PHP intercepts the string length (a mix of Chinese and English strings ). The article introduces the string truncation function from the built-in php truncation function to the final support of Chinese characters. the introduction of the mixed string truncation method in English and Chinese english. if you need it, ref
.
PHP to obtain in English mixed string length of the implementation code is as follows, 1 Chinese = 1 bits, 2 english = 1 bits, can be modified
The code is as follows
Copy Code
/*** php Get string in English mix length* @param $str string* @para
I. Prefacerecently learning a little intermittent, some of the knowledge points are not complete, or completely do not understand, not good to take the stage face, or first in the draft box lying. Occasionally when browsing Daniel blog http://coolshell.cn , found that Daniel's spare time is also doing programming training http://coolshell.cn/articles/12052. HTML, as a test ape who wants to be an inspirational farmer, should use spare time to train his
characters in Java are stored in 16-bit, it probably takes 4GB of memory to store the maximum length of the string.
But this is only for string variables, if it is string constants, such as "ABC", "1234" and so on in the code of string str, then the maximum allowable
Tip: (1) when calculating the length of a string, the key is to recognize the escape character. (2) an escape character always starts with a backslash and is composed of another character. Therefore, pay special attention to the backslash !!!
1. A string without escape characters
For example, "ABC! X =/", whose length
returned.When multiple variables are checked at the same time, TRUE is returned only when each individual item meets the previous requirement; otherwise, the result is FALSE.If unset () is used to release a variable, it will no longer be isset (). If you use isset () to test a variable that is set to NULL, FALSE is returned. Note that a NULL byte ("") is not equivalent to the NULL constant of PHP.
Warning: isset () can only be used for variables, bec
omit the second argument, the internal encoding of PHP is used. The internal code can be obtained through the mb_internal_encoding () function.
It is important to note that Mb_strlen is not a PHP core function and needs to be sure that the Php_mbstring.dll is loaded in the php.ini before use, that is, to ensure that the "Extension=php_mbstring.dll" line is present and not commented out. Otherwise, there is an issue with undefined functions.
The strlen function measures the
nvarchar (max) length test: Text length can exceed the upper limit of 8000 after using convert to force type conversions.and the maximum length of nvarchar (max) can reach 2^31The following is the validation sql:Declare @A nvarchar (max) set @a=replicate (' * ', 9000);p rint len (@A) Set @a=replicate (CONVERT (nvarchar
PHP string length function, in PHP test string length function has two, one is strlen, the other is Mb_strlen before a default is supported, the latter need to open a plug-in, let us introduce the difference between the two functions and application methods.
PHP Tutorial
. length (); int [] prefixlen = new int [n + 1]; prefixlen [N] = 0; int [] maxlenstart = new int [n + 1]; maxlenstart [N] = N; int [] maxlenend = new int [n + 1]; maxlenend [N] = n-1; For (INT I = n-1; I> = 0; I --) {char c = Str. charat (I); // caculate prefixlen [I] By prefixlen [I + 1] Int J = 0, K; For (j = 0, K = I + 1; j
Test output:
Max Len of substring with unique chars for
obtained through the mb_internal_encoding () function.
It should be noted that mb_strlen is not a PHP core function. before using it, make sure that. the "php_mbstring.dll" line is loaded in ini to ensure that the "extension = php_mbstring.dll" line exists and is not commented out. Otherwise, the number of undefined functions may occur.
The strlen function measures the string length to include the end iden
for execution.
The following is an example of how to judge the string length through isset () and strlen:
$ Str = 'HTTP: // www.phpernote.com/php-template/436.html'{if (strlen ($ str)
Next we will analyze the strlen () and isset () functions in detail.
PHP strlen () function
Definition and usage
The strlen () function returns the length of the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.