Programming PHP How to check variable types in PHP

How to check variable types in PHP

How to check variable types in PHP - techbriefers.com

To check variable types in PHP, we have many variable handling functions available. Below is the list of functions I am going to explain.

Function list to check variable types.

  1. is_array()
  2. is_​bool()
  3. is_​double()
  4. is_​float()
  5. is_​int()
  6. is_​long()
  7. is_​integer()
  8. is_​numeric()
  9. is_​object()
  10. is_​resource()
  11. is_​null()
  12. is_​string()

is_​array() function in PHP

PHP is_​array() function checks whether the passed argument is an array type or not.
Returns true if argument is array, otherwise returns false.

is_​bool() function in PHP

PHP is_​bool() function checks whether the passed argument is of Boolean type (true/false) or not.
Returns true if argument is Boolean type, otherwise returns false.

is_double() function in PHP

PHP is_​double() function checks whether the passed argument is of double/float/real type or not.
Returns true if argument is double/float/real type, otherwise returns false.

is_​float() function in PHP

PHP is_​float() function is alias of is_​double() function.

is_​real() function in PHP

PHP is_​real() function is alias of is_​double() function.

is_​int() function in PHP

PHP is_​int() function checks whether the passed argument is is of type integer or not.
Returns true if argument is integer type, otherwise returns false.

is_​long() function in PHP

PHP is_​long() function is alias of is_​int() function.

is_​integer() function in PHP

PHP is_​integer() function is alias of is_​int() function.

is_​numeric() function in PHP

PHP is_​numeric() function checks whether the passed argument is a numeric type value or not.
Returns true if argument is numeric type, otherwise returns false.

is_​null() function in PHP

PHP is_​null() function checks whether the passed argument is a null value or not.
Returns true if argument is null, otherwise returns false.

is_object() function in PHP

PHP is_object() function checks whether the passed argument is an object i.e, instance of class or not.
Returns true if argument is instance of class, otherwise returns false.

is_resource() function in PHP

PHP is_resource() function checks whether the passed argument is a resource or not.
Returns true if argument is a resource, otherwise returns false.

is_​string() function in PHP

PHP is_​string() function checks whether the passed argument is a string or not.
Returns true if argument is a string, otherwise returns false.

Leave a Reply