CKTIS / PHP
PHP_INT_MAX / PHP_INT_MIN
Das Paar PHP_INT_MAX / PHP_INT_MIN bezeichnet die größte und kleinste vorzeichenbehaftete Ganzzahl je nach Integerbreite des Builds.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
$overflow = PHP_INT_MAX + 1;Das Paar PHP_INT_MAX / PHP_INT_MIN bezeichnet die größte und kleinste vorzeichenbehaftete Ganzzahl je nach Integerbreite des Builds. Die Untergrenze ist -PHP_INT_MAX - 1. Gewöhnliche Addition oder Subtraktion über eine Grenze hinaus ergibt float, der nicht alle großen ganzen Zahlen exakt darstellt.
$above = PHP_INT_MAX + 1;
$below = PHP_INT_MIN - 1;
echo json_encode([
PHP_INT_MIN === -PHP_INT_MAX - 1,
get_debug_type(PHP_INT_MAX), get_debug_type(PHP_INT_MIN),
get_debug_type($above), get_debug_type($below)
]);
[true,"int","int","float","float"]
Beispiele
<?php
$above = PHP_INT_MAX + 1;
$below = PHP_INT_MIN - 1;
echo json_encode([
PHP_INT_MIN === -PHP_INT_MAX - 1,
get_debug_type(PHP_INT_MAX), get_debug_type(PHP_INT_MIN),
get_debug_type($above), get_debug_type($below)
]);
Ergebnis
[true,"int","int","float","float"]