English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Grundanleitung

PHP Fortgeschrittene Anleitung

PHP & MySQL

PHP Referenzhandbuch

PHP is_int() 、is_integer()、is_long() Funktionssyntax und Beispiel

PHP verfügbare Funktionen

is_int() Die Funktion wird verwendet, um zu überprüfen, ob eine Variable eine Ganzzahl ist.

Hinweis: Um zu überprüfen, ob eine Variable eine Zahl oder eine numerische Zeichenkette ist (z.B. Formular-Eingaben, die normalerweise Zeichenketten sind), muss is_numeric()

Alias-Funktion():is_integer()、is_long() 。

PHP Versionsanforderungen: PHP 4, PHP 5, PHP 7

Syntax

bool is_int ( gemischt $var )

Parameterbeschreibung:

  • $var:Zu überprüfende Variable.

Rückgabewert

Gibt TRUE zurück, wenn die angegebene Variable eine Ganzzahl ist, anderenfalls FALSE.

Online-Beispiel

<?php
$var_name1=678;
$var_name2="a678";
$var_name3="678";
$var_name4=999;
$var_name5=698.99;
$var_name6=array("a1","a2");
$var_name7=+125689.66;
if (is_int($var_name1))
{
    echo "$var_name1 Es ist eine Ganzzahl" . PHP_EOL ;
}
else
{
echo "$var_name1 Es ist keine Ganzzahl" . PHP_EOL ;
}
if (is_int($var_name2))
{
echo "$var_name2 Es ist eine Ganzzahl" . PHP_EOL ;
}
else
{
echo "$var_name2 Es ist keine Ganzzahl" . PHP_EOL ;
}
$result=is_int($var_name3);
echo "[ $var_name3 Ist es eine Ganzzahl? ]" .var_dump($result) . PHP_EOL;
$result=is_int($var_name4);
echo "[ $var_name4 Ist es eine Ganzzahl? ]" .var_dump($result) . PHP_EOL;
$result=is_int($var_name5);
echo "[ $var_name5 Ist es eine Ganzzahl? ]" .var_dump($result) . PHP_EOL;
$result=is_int($var_name6);
echo "[ $var_name6 Ist es eine Ganzzahl? ]" .var_dump($result) . PHP_EOL;
$result=is_int($var_name7);
echo "[ $var_name7 Ist es eine Ganzzahl? ]" .var_dump($result);
?>

Das Ausgaberesultat lautet:

678 Es ist eine Ganzzahl
a678 Es ist keine Ganzzahl
bool(false)
[ 678 Ist es eine Ganzzahl? ]
bool(true)
[ 999 Ist es eine Ganzzahl? ]
bool(false)
[ 698.99 Ist es eine Ganzzahl? ]
bool(false)
[ Array Ist es eine Ganzzahl? ]
bool(false)
[ 125689.66 Ist es eine Ganzzahl? ]

PHP verfügbare Funktionen