Ec (2); how can I intercept Chinese strings in the cakephp tutorial? The Text-& gt; truncate method has three parameters: $ text: string to be truncated $ length: The length to be truncated. The default value is to intercept 100 characters $ options: array parameter. Ending indicates adding the ending string at the end of the intercepted string; if the value of exact is false, the word is not truncated; if the value of html is true, the script ec (2) under the htmltag is not truncated ); script
How to intercept a Chinese string in the cakephp tutorial?
The Text-> truncate method has three parameters:
$ Text: string to be truncated
$ Length: The length to be intercepted. The default value is 100 characters.
$ Options: array parameter. Ending indicates adding the ending string to the end of the intercepted string. If the value of exact is false, the word is not truncated. If the value of html is true, the html tag is not truncated.
The following code demonstrates how to use the tuncate method:
View sourceprint? Echo $ this-> Text-> truncate (
'The killer crept forward and tripped on The rug .',
22,
Array (
'Ending' => '...',
'Delete' => false
)
);
The above code will output The killer crept...
Note: If you want to intercept Chinese strings, it is best to set exact to true. Otherwise, Chinese characters cannot be truncated.