w3resource
PHP Tutorial

PHP: is_long() function

Description

The is_long() function is used to test whether the type of the specified variable is an integer or not. The function is an alias of is_int().

Version:

(PHP 4 and above)

Syntax:

is_long(var_name)

Parameter:

Name Description Required /
Optional
Type
var_name The variable being checked Required Mixed*

*Mixed: Mixed indicates that a parameter may accept multiple (but not necessarily all) types.

Return value:

TRUE if var_name is an integer, FALSE otherwise.

Value Type: Boolean

Example:

<?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_long($var_name1))
{
echo "$var_name1 is long number.<br>" ;
}
else
{
echo "$var_name1 is not an long number.<br>" ;
}
if (is_long($var_name2))
{
echo "$var_name2 is long number.<br>" ;
}
else
{
echo "$var_name2 is not long number.<br>" ;
}
$result=is_long($var_name3);
echo "[ $var_name3 is long number? ]" .var_dump($result)."<br>";
$result=is_long($var_name4);
echo "[ $var_name4 is long number? ]" .var_dump($result)."<br>";
$result=is_long($var_name5);
echo "[ $var_name5 is long number? ]" .var_dump($result)."<br>";
$result=is_long($var_name6);
echo "[ $var_name6 is long number? ]" .var_dump($result)."<br>";
$result=is_long($var_name7);
echo "[ $var_name7 is long number? ]" .var_dump($result);
?>        

Output:

678 is long number.
a678 is not long number.
bool(false)  [ 678 is long number? ]
bool(true)  [ 999 is long number? ]
bool(false)  [ 698.99 is long number? ]
bool(false)  [ Array is long number? ]
bool(false)  [ 125689.66 is long number? ]

View the example in the browser

Practice here online :

See also

PHP Function Reference

Previous: is_integer
Next: is_null