Overview

PHP’s variable-related functions are a key part of the language. Skilled programmers rely on them extensively to build robust code that uses type-checking. Functions like var_dump() and print_r() are also invaluable when debugging.

Here is a quick, task-based overview of the function group:

  • Cast a value from one type to another: doubleval(), intval(), strval()

  • Set the type of a variable: settype()

  • Determine the type of a variable: is_array(), is_bool(), is_double(), is_float(), is_int(), is_integer(), is_long(), is_null(), is_numeric(), is_object(), is_real(), is_resource(), is_scalar(), is_string(), get_resource_type(), gettype()

  • Destroy variables: unset()

  • Gather information about variables: empty(), get_defined_vars(), isset(), print_r() ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.