CKTIS / PHP
PHP_INT_MAX / PHP_INT_MIN
La coppia PHP_INT_MAX / PHP_INT_MIN indica l’intero con segno massimo e minimo secondo la larghezza degli interi della build.
Versione: PHP 8.4; repository runtime, production runtime not attested
Sintassi
$overflow = PHP_INT_MAX + 1;La coppia PHP_INT_MAX / PHP_INT_MIN indica l’intero con segno massimo e minimo secondo la larghezza degli interi della build. Il limite inferiore vale -PHP_INT_MAX - 1. Sommare o sottrarre oltre i limiti produce float, che non rappresenta esattamente tutti i grandi interi.
$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"]
Esempi
<?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)
]);
Risultato
[true,"int","int","float","float"]