Types

19 entries

ctype_digit Function Checks whether every character of the string is a decimal digit 0-9 (narrow ASCII semantics); entry point of the Ctype character-checking family. the ctype_* family Function Aggregate of the other nine ctype functions: alnum/alpha/lower/upper/space/xdigit/graph/print/punct, all narrow-ASCII; compared with each language's ASCII-narrow and Unicode-wide schools (ctype_digit has its own entry). filter_input Function Fetches a variable by name from a superglobal input source with optional filtering: INPUT_GET/POST/COOKIE/SERVER/ENV/REQUEST constants pick the source, FILTER_VALIDATE_*/SANITIZE_* pick the filter. It reads the SAPI's ORIGINAL input, not your modified superglobal copy; unset returns null, filter failure returns false (FILTER_NULL_ON_FAILURE swaps the semantics). Under CLI, GET/POST/COOKIE are always null - an honest environment-independent demo. filter_var Function Validates or sanitizes a value with a built-in dictionary of filters: the FILTER_VALIDATE_* family validates (false on failure, or null with FILTER_NULL_ON_FAILURE), the FILTER_SANITIZE_* family sanitizes - PHP's unique "validation dictionary" ecosystem. get_debug_type Function Returns a variable's real type name (PHP 8.0+): float/int/stdClass, contrasted with gettype's historical double/integer - always prefer it for debugging. intval / floatval / strval / boolval Function The four explicit conversion functions. Trap table: intval('123abc')=123 (prefix parsing), boolval('0')=false (the only falsy string), all equivalent to the (int)/(bool) operators. is_array Function Finds whether a variable is an array. is_bool Function Finds whether a variable is a boolean. is_callable Function Verifies whether a value can be called as a function in the current scope (a closure, a function-name string, or an [object, method] array). is_countable Function Checks whether a value can be counted with count() (array or Countable, PHP 7.3+). Contrasts the everything-has-length camp (len()/length asks the object directly) with the explicit-interface camp (count requires Countable). is_float Function Exact float-type check: true only for the float type - int is a different type and numeric strings stay strings (is_numeric tests those); is_double is an alias. is_int Function Finds whether a variable is of integer type. is_iterable Function Checks whether a value can be traversed with foreach (array or Traversable, PHP 7.1+). Contrasts three camps: Python/JS protocol style, Go/Rust compile-time style, Java/C# interface style. is_null Function Finds whether a variable is null. is_numeric Function Finds whether a variable is a number or a numeric string. is_scalar / is_object / is_resource Function Scalar/object/resource triple check rounding out PHP's type system: scalar = bool/int/float/string; resource is unique to PHP (an external handle), matched elsewhere by Closeable, FILE*, OwnedFd and friends. is_string Function Finds whether a variable is a string. get_resource_type / get_resource_id / get_resources Function Resource introspection: get_resource_type reads the handle's type name (e.g. stream), get_resource_id its numeric id, and get_resources lists currently live resources (optionally filtered by type; debugging tool). settype Function Changes a variable's type in place (bool/int/float/string/array/object/null...) - the by-reference conversion is the odd one out: every other language returns a new value with types fixed.