❮ PHP Variable Handling Reference
Check whether a variable is of type string or not:
<?php
$a = "Hello";
echo "a is " . is_string($a) . "<br>";
$b = 0;
echo "b is " . is_string($b) . "<br>";
$c = 32;
echo "c is " . is_string($c) . "<br>";
$d = "32";
echo "d is " . is_string($d) . "<br>";
$e = true;
echo "e is " . is_string($e) . "<br>";
$f = "null";
echo "f is " . is_string($f) . "<br>";
$g = "";
echo "g is " . is_string($g) . "<br>";
?>
Try it Yourself »
The is_string() function checks whether a variable is of type string or not.
This function returns true (1) if the variable is of type string, otherwise it returns false/nothing.
is_string(
variable);
Parameter | Description |
---|---|
variable | Required. Specifies the variable to check |
Return Value: | TRUE if variable is a string, FALSE otherwise |
---|---|
Return Type: | Boolean |
PHP Version: | 4.0+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!