$name = "John Doe"; if (is_string($name)) { echo "Name is a string"; } else { echo "Name is not a string"; }
$age = 25; if (is_string($age)) { echo "Age is a string"; } else { echo "Age is not a string"; }In this example, we validate if the variable `$age` is a string using the `is_string` function. It would return "Age is not a string". The `is_string` function is a built-in function in PHP, and does not need any package or library to be installed. It is available in all versions of PHP.