❮ PHP Variable Handling Reference
Check whether a variable is a scalar or not:
<?php
$a = "Hello";
echo "a is " . is_scalar($a) . "<br>";
$b = 0;
echo "b is " . is_scalar($b) . "<br>";
$c = 32;
echo "c is " . is_scalar($c) . "<br>";
$d = NULL;
echo "d is " . is_scalar($d) . "<br>";
$e = array("red", "green", "blue");
echo "e is " . is_scalar($e) . "<br>";
?>
Try it Yourself »
The is_scalar() function checks whether a variable is a scalar or not.
This function returns true (1) if the variable is a scalar, otherwise it returns false/nothing.
Integers, floats, strings, or boolean can be scalar variables. Arrays, objects, and resources are not.
is_scalar(
variable);
Parameter | Description |
---|---|
variable | Required. Specifies the variable to check |
Return Value: | TRUE if variable is a scalar, FALSE otherwise |
---|---|
Return Type: | Boolean |
PHP Version: | 4.0.5+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!