PHP 8.4: PHP_ZTS
and PHP_DEBUG
constant value type changed from int
to bool
PHP_ZTS
and PHP_DEBUG
are two PHP global constants that provide information about the current PHP run-time.
PHP_ZTS
: Indicates whether the current build of PHP is thread-safe. The same value asZEND_THREAD_SAFE
constant.PHP_DEBUG
: Indicates whether the current build of PHP is a debug build. Same value asZEND_DEBUG_BUILD
.
Prior to PHP 8.4, these two constants contained integer values: 0
when disabled, and 1
when enabled. Since PHP 8.4 and later, they have changed to boolean values.
Backward Compatibility Impact
The updated values continue to be "truthy" and "falsy", and type insensitive comparisons such as 1 == true
and 0 == false
will continue to work even after this change.
Applications that use strict comparisons with PHP_ZTS
and PHP_DEBUG
constants will need to account for this type change in PHP 8.4.
For compatibility across PHP 8.4 and older versions:
- if (PHP_ZTS === 1) {}
+ if (PHP_ZTS === 1 || PHP_ZTS === true) {}
- if (PHP_DEBUG === 1) {}
+ if (PHP_DEBUG === 1 || PHP_DEBUG === true) {}
For PHP >= 8.4 only:
- if (PHP_ZTS === 1) {}
+ if (PHP_ZTS) {}
- if (PHP_DEBUG === 1) {}
+ if (PHP_DEBUG) {}
Alternately, PHP_ZTS
and PHP_DEBUG
constants can be replaced with ZEND_THREAD_SAFE
and ZEND_DEBUG_BUILD
constants that contain the same values as boolean values across all PHP versions.
- if (PHP_ZTS === 1) {}
+ if (ZEND_THREAD_SAFE) {}
- if (PHP_DEBUG === 1) {}
+ if (ZEND_DEBUG_BUILD) {}