How many bytes does one character occupy in php?

zbt
Release: 2023-06-13 09:18:11
Original
1438 people have browsed it

The bytes occupied by characters in different encoding formats in php are different, which are: 1. ANSI Chinese characters occupy 2 bytes, and English characters occupy 1 byte; 2. UTF-8 Chinese characters Occupying 3 bytes, English characters occupy 1 byte; 3. Unicode Chinese characters occupy 2 bytes, and English characters occupy 2 bytes.

How many bytes does one character occupy in php?

The operating environment of this tutorial: windows10 system, php8.1.3 version, DELL G3 computer.

The bytes occupied by characters in different encoding formats are different:

ANSI Chinese characters occupy 2 bytes and English characters occupy 1 byte;

UTF-8 Chinese characters occupy 3 bytes and English characters occupy 1 byte;

Unicode Chinese characters occupy 2 bytes and English characters occupy 2 bytes;

Talk about the difference between characters and bytes:

(1) Definition of "byte"

Byte (Byte) is a unit of measurement that represents data It is a unit of measurement used by computer information technology to measure storage capacity.

(2) Definition of "Character"

Characters refer to the words and symbols used in computers, such as 1, 2, 3, A, B, C, ~!·#¥% ……-*()-- ,etc.

Numbers, letters and other symbols are characters. Characters only occupy one byte, and Chinese characters occupy two (UTF-8).

The above is the detailed content of How many bytes does one character occupy in php?. 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 Articles by Author
Popular Tutorials
More>
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!