Home > Article > Backend Development > What should I do if php exceeds the character length?
Solution to php exceeding the character length: 1. Create a PHP sample file; 2. Display characters of the specified length through the "function cutSubstr($str,$len=30){...}" method String, and when the characters exceed the length, the tail is filled with ellipsis and displayed.
#The operating environment of this article: Windows7 system, PHP7.1, Dell G3.
What should I do if php exceeds the character length?
php displays a string of specified length. If the length exceeds the length, fill in the tail with an ellipsis (...) and display
/** * php显示指定长度的字符串,超出长度以省略号(...)填补尾部显示 * @ str 字符串 * @ len 指定长度 **/ function cutSubstr($str,$len=30){ if (strlen($str)>$len) { $str=substr($str,0,$len) . '...'; } return $str; }
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What should I do if php exceeds the character length?. For more information, please follow other related articles on the PHP Chinese website!