PHP function is_scalar()

11. 9. 2019

Availability in versions: PHP 4.0.5

Checks if the input is a scalar value.

Scalar variables are variables containing integer (integer), float, string or boolean. The array, object and resource types are not scalar.

Note: The value null is not scalar!

Note:

is_scalar() does not consider values of type resource to be scalar because it is an abstract data type (which may change over time). This implementation detail should not be relied upon as it may change.

Parameters

Parameter Data type Default value Note
$var mixed not Variable to be checked

Return values

bool

Returns true if the input is scalar. Otherwise false.

Other resources

[Official is-scalar documentation](Official documentation)

Jan Barášek
Jan BarášekVíce o autorovi

Autor článku pracuje jako seniorní vývojář a software architekt v Praze. Navrhuje a spravuje velké webové aplikace, které znáte a používáte. Od roku 2009 nabral bohaté zkušenosti, které tímto webem předává dál.

Rád vám pomůžu:

Newsletter

Nejlepsi tipy a triky o PHP do Vaseho e-mailu. Clanky a novinky nejen ze sveta PHP a programovani.