Strings in PHP explained in detail

墨辰丷
Release: 2023-03-25 17:14:01
Original
1590 people have browsed it

String is one of the commonly used data types in PHP and is often used in our daily PHP development. A string is a sequence of characters composed of numbers, letters, and underscores. It is a data type that represents text in programming languages. Strings are stored like character arrays, so each individual element of a string can be extracted.

1. mb_strimwidth string interception function uses & UTF8 encoding understanding

'; echo mb_strwidth("A", "UTF-8") . '
'; echo mb_strwidth("a", "UTF-8") . '
'; echo mb_strwidth("月", "UTF-8") . '
'; echo mb_strwidth("6月9日OUR系统升级通知", "UTF-8") . '
'; echo mb_strimwidth("6月9日OUR系统升级通知", 0, 10, '...') .'
'; echo mb_strimwidth("6月9日OUR系统升级通知", 0, 10, '...', "UTF-8") .'
'; echo mb_strimwidth("6月9日OUR系统升级通知", 0, 10, '......', "UTF-8") .'
'; echo mb_strimwidth("6月9日OUR系统升级通知", 0, 10, '', "UTF-8") .'
'; ?>
Copy after login

This function requires the system to load mb (multi-byte ) extension, the $trimmarker parameter will affect the result, and its length is also included in the result.

Recommended related articles:

PHP string encryption enhanced version

PHP string definition Methods and their differences

How to convert PHP strings into arrays


The above is the detailed content of Strings in PHP explained in detail. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!