PHP is_string() Function

PHP print_r() Function
PHP is_scalar() Function

In this article, you will learn how to check if a variable type is string in PHP. The PHP 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.

what is the syntax of theIS_STRING() function in php?

is_string(variable);
ParametersDetails
variableRequired. Specifies the variable to check
PHP IS_STRING() method

examples of the IS_STRING() function

Example 1. In this example, we 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>";
?>
PHP print_r() Function
PHP is_scalar() Function
en English
X
Scroll to Top