Web студия "GrandView"
  Главная   Написать Контакты
   
   
О проекте
Руководство php
 

Предопределенные константы

Содержание
Объявленные в ядре константы -- Константы, объявленные в ядре PHP, Zend, и SAPI-модулях
Стандартные константы -- Константы, объявленные в PHP по умолчанию


add a note add a note User Contributed Notes
Предопределенные константы
josharian at gmail dot com
18-Oct-2007 08:56
@docey:

Unfortunately, that will not work -- PHP will convert (PHP_INT_MAX+1) to a float.

At least on my system, the minimum integer size is -PHP_INT_MAX - 1. I would say that that should be reliable elsewhere, but PHP ints have known portability issues -- see e.g. http://preview.tinyurl.com/ywh7ya

Confirm this way:

<?php

echo gettype(PHP_INT_MAX) . "\n";
echo
gettype(PHP_INT_MAX + 1) . "\n";
echo
gettype(-PHP_INT_MAX) . "\n";
echo
gettype(-PHP_INT_MAX - 1) . "\n";
echo
gettype(-PHP_INT_MAX - 2) . "\n";

?>

On my system this yields:

integer
double
integer
integer
double

It would be nice to have a PHP_INT_MIN, though. Even better would be to have reliable, predictable data types...
docey
30-Aug-2007 01:22
a simple way of getting the minium allowed integer value is by adding 1 to the PHP_INT_MAX constant value. it causes the signed integer to roll over from the maxium integer size to the minium integer size.
Tea Bore
28-Sep-2005 12:09
Use get_defined_constants() to retrieve these constants.

<?php

print '<pre>';
print_r(get_defined_constants());
print
'</pre>';

?>

 
Новости
11 июля 2007
Сайт запущен
© 2007 info@grandviewstudio.com

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 324

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 330
Z058440144362 Z348613067571