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.
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 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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version
Useful JavaScript development tools
