English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP is_string() function usage and example

PHP available functions

is_string() The function is used to check if a variable is a string.

PHP version requirement: PHP 4, PHP 5, PHP 7

Syntax

bool is_string ( mixed $var )

Parameter description:

  • $var: The variable to be checked.

Return value

Returns TRUE if the specified variable is a string, otherwise returns FALSE.

Online Example

<?php
if (is_string("2663))
    echo 'This is a string.' . PHP_EOL;
else
    echo 'This is not a string.';
var_dump(is_string('XYZ'));
var_dump(is_string("99"));
var_dump(is_string("123.05));
var_dump(is_string(false));
?>

The output is:

This is a string.
bool(true)
bool(true)
bool(false)
bool(false)

PHP available functions