note 83055 modified in reserved.constants by danbrown
| From: | danbrown@php.net | Date: | Sat, 13 Jun 2009 01:37:34 +0000 |
| Subject: | note 83055 modified in reserved.constants by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-156833@lists.php.net to get a copy of this message | ||
As PHP_INT_MAX is only available since PHP 4.4.0 and PHP 5.0.5 here is a function that should enable
sensible values on most machines (16,32 & 64bit):-
<?php
function get_int_max()
{
$max=0x7fff;
$probe = 0x7fffffff;
while ($max == ($probe>>16))
{
$max = $probe;
$probe = ($probe << 16) + 0xffff;
}
return $max;
}
if (!defined('PHP_INT_MAX'))
{
define ('PHP_INT_MAX', get_int_max());
}
define ('PHP_INT_MIN', (int)(PHP_INT_MAX+1));
?>
--was--
As PHP_INT_MAX is only available since PHP 4.4.0 and PHP 5.0.5 here is a function that should enable
sensible values on most machines (16,32 & 64bit):-
function get_int_max()
{
$max=0x7fff;
$probe = 0x7fffffff;
while ($max == ($probe>>16))
{
$max = $probe;
$probe = ($probe << 16) + 0xffff;
}
return $max;
}
if (!defined('PHP_INT_MAX'))
{
define ('PHP_INT_MAX', get_int_max());
}
define ('PHP_INT_MIN', (int)(PHP_INT_MAX+1));
http://php.net/manual/en/reserved.constants.php