PHP Variable Functions

Beginner
6 min read
Updated: Nov 2026
37 function guides
Function index

About This Index

This page is the PHP Variable Functions index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs for one function or language construct that works with variables and types.

Learn how to test types, cast values, check existence, debug and serialize on /php/variable. Use this page when you need the details of one function such as intval(), isset(), or var_dump().

Five groups, 37 guides.

The functions are grouped by job: cast and convert, type tests, existence, inspect and debug, and serialize. If you are not sure where to start, read PHP Variables first.

isset(), empty() and unset() are language constructs.

They are written like functions, but they are part of the PHP language itself. You cannot pass them as callbacks or call them through a variable name.

How to Call a PHP Variable Function

Every function is global—call it directly, with no object and no namespace. One example from each group:

PHP
$n = intval("42abc");              // int: 42             (cast and convert)
$ok = is_numeric("1e3");           // bool: true          (type test)
$set = isset($user['name']);       // bool                (existence)
$type = get_debug_type(1.5);       // string: "float"     (inspect and debug)
$text = serialize([1, 2, 3]);      // string              (serialize)

var_dump($n);                      // prints int(42), returns nothing
$copy = print_r([1, 2], true);     // true as 2nd argument returns a string
unset($n);                         // removes the variable

PHP Variable Functions Table

All function guides in this PHP tutorial series (37 tutorials in 5 categories). Aliases and the removed is_real() are marked in their rows.

Cast & convert

6 functions

Change a value from one type to another. Each function has a matching cast: (int), (float), (string) and (bool). settype() changes the variable itself.

FunctionDescriptionTutorial
boolval()Convert a value to a boolean.Try it
floatval()Convert a value to a float.Try it
doubleval()Alias of floatval().Try it
intval()Convert a value to an integer, in any base.Try it
strval()Convert a value to a string.Try it
settype()Change the type of a variable in place.Try it

Type tests

17 functions

Ask what type a value has. Every is_* function returns true or false and never changes the value.

FunctionDescriptionTutorial
is_array()Check whether a value is an array.Try it
is_bool()Check whether a value is a boolean.Try it
is_callable()Check whether a value can be called as a function.Try it
is_countable()Check whether a value can be used with count().Try it
is_float()Check whether a value is a float.Try it
is_double()Alias of is_float().Try it
is_real()Old alias of is_float(). Removed in PHP 8.0.Try it
is_int()Check whether a value is an integer.Try it
is_integer()Alias of is_int().Try it
is_long()Alias of is_int().Try it
is_iterable()Check whether a value can be used in foreach.Try it
is_null()Check whether a value is null.Try it
is_numeric()Check whether a value is a number or a numeric string.Try it
is_object()Check whether a value is an object.Try it
is_resource()Check whether a value is an open resource.Try it
is_scalar()Check whether a value is an int, float, string or bool.Try it
is_string()Check whether a value is a string.Try it

Existence

3 functions

Decide whether a variable exists and holds a useful value. These three are language constructs, not real functions, but they are written like functions.

FunctionDescriptionTutorial
isset()Check that a variable exists and is not null.Try it
empty()Check that a variable is missing or holds a falsy value.Try it
unset()Remove a variable or an array element.Try it

Inspect & debug

9 functions

Look inside a variable. Some functions print the value, some return its type name, and some describe resources or the whole scope.

FunctionDescriptionTutorial
gettype()Get the legacy type name, such as integer or double.Try it
get_debug_type()Get the modern type name, such as int or a class name (PHP 8.0+).Try it
var_dump()Print the type and value of a variable.Try it
print_r()Print a readable form of a variable, or return it as a string.Try it
var_export()Print or return a variable as valid PHP code.Try it
debug_zval_dump()Print a variable together with its internal reference count.Try it
get_defined_vars()Return every variable in the current scope as an array.Try it
get_resource_id()Get the numeric ID of a resource (PHP 8.0+).Try it
get_resource_type()Get the type name of a resource, such as stream.Try it

Serialize

2 functions

Turn a value into a string that can be stored, and turn it back. Never unserialize data that you do not trust.

FunctionDescriptionTutorial
serialize()Turn a value into a storable string.Try it
unserialize()Rebuild a value from a serialized string.Try it

Aliases and Removals

Several names in this index do the same job. Pick the preferred name and use it throughout your code:

AliasPreferred functionStatus
doubleval()floatval()Alias, still works
is_double()is_float()Alias, still works
is_integer()is_int()Alias, still works
is_long()is_int()Alias, still works
is_real()is_float()Removed in PHP 8.0; calling it is a fatal error
Check old code for is_real().

is_real() was deprecated in PHP 7.4 and removed in PHP 8.0. If you upgrade an old project, replace it with is_float(). The (real) cast was removed at the same time, so use (float).

Frequently Asked Questions

They are the built-in functions and language constructs for handling variables and their types: converting values (intval(), floatval(), strval(), boolval(), settype()), testing types (the is_* family), checking existence (isset(), empty(), unset()), inspecting values (gettype(), get_debug_type(), var_dump(), print_r(), var_export() and others), and storing values as text (serialize() and unserialize()).
doubleval() is an alias of floatval(). is_double() is an alias of is_float(). is_integer() and is_long() are aliases of is_int(). An alias does exactly the same job, so pick one name and use it everywhere. The preferred names are floatval(), is_float() and is_int().
Yes. is_real() was an alias of is_float() that was deprecated in PHP 7.4 and removed in PHP 8.0, so calling it on PHP 8 is a fatal error. Replace it with is_float(). The (real) cast was removed in the same release; use (float).
No, they are language constructs, handled by the PHP parser itself. They look like function calls, but you cannot store them in a variable, pass them as callbacks, or use them with call_user_func(). They are in this index because they belong with the other variable tools and are written the same way.
The PHP Variables page teaches the ideas with working examples: how to test types, cast values, check existence, debug with var_dump() and print_r(), and use serialize() safely. This index lists a guide for each of the 37 functions, so you can jump straight to the one you need.
Start with isset(), empty(), is_numeric(), intval() and var_dump(). Together they cover most daily work: checking input, converting it, and seeing what a variable really holds. After that, learn settype(), get_debug_type() and the other is_* functions as you need them.

Start with boolval()

Open the next guide—syntax, examples, and FAQs.

boolval() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful