Encodera

Thanks for reading!

Donate to the site — we work hard for you.

PHP reference

is_string

Checks whether a value is a string.

Syntax

is_string(mixed $value): bool

Parameters

ParameterTypeDescription
$valuemixedThe value to check.

Return value

bool`true` if the value is a string.

Examples

A string and a number:

<?php
 
var_dump(is_string('42'));
var_dump(is_string(42));

Output:

bool(true)
bool(false)

Notes

A string holding a number is still a string. To find out whether it looks like a number, use is_numeric().

See also

  • is_array — Checks whether a value is an array.
  • is_int — Checks whether a value is an integer.
  • gettype — Returns the name of a value's type.

In the tutorial

  • Data types — The main PHP data types — strings, numbers, booleans, arrays and null.

Thanks for reading!

Donate to the site — we work hard for you.