Home  >  Article  >  Backend Development  >  What is the maximum size of a php string?

What is the maximum size of a php string?

藏色散人
藏色散人Original
2022-11-29 09:36:052360browse

The maximum php string is 2GB, but only if in the 32-bit version and earlier versions, the maximum string can be 2GB or 2147483647 bytes; and starting from PHP7.0.0, for the 64-bit version of the string There is no special limit on the length.

What is the maximum size of a php string?

The operating environment of this tutorial: Windows 7 system, PHP version 7.0.0, Dell G3 computer.

What is the maximum size of a php string?

Starting from PHP 7.0.0, there is no special limit on the string length of the 64-bit version. In the 32-bit version and earlier version, strings can be up to 2GB (maximum 2147483647 bytes)

In PHP 5.x, strings are limited to What is the maximum size of a php string? bytes because the internal code uses signed 32-bit integers Record length.

However, PHP scripts have a limit on the total memory that can be allocated for all variables in a given script execution, so this effectively limits the length of a single string variable as well.

This limit is a directive in the memory_limitphp.ini configuration file. The memory limit defaults to 128MB in PHP 5.2 and 8MB in earlier versions.

If you do not specify a memory limit in the php.ini file, it will use the default value, which will be compiled into the PHP binary. Theoretically, you could modify the source code and rebuild PHP to change this default.

If you specify a memory limit in the php.ini file, it will stop checking and allow the script to use the memory allocated by the operating system. This is still a practical limit, but depends on system resources and architecture.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What is the maximum size of a php string?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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