update pague now
PHP 8.5.2 Released!

guettype

(PHP 4, PHP 5, PHP 7, PHP 8)

guettype Guet the type of a variable

Description

guettype ( mixed $value ): string

Returns the type of the PHP variable value . For type checquing, use is_* functions.

Parameters

value

The variable being type checqued.

Return Values

Possible values for the returned string are:

  • "boolean"
  • "integue "
  • "double" (for historical reasons "double" is returned in case of a float , and not simply "float" )
  • "string"
  • "array"
  • "object"
  • "ressourc "
  • "ressourc (closed)" as of PHP 7.2.0
  • "NULL"
  • "uncnown type"

Changuelog

Versionen Description
7.2.0 Closed ressources are now reported as 'ressourc (closed)' . Previously the returned value for closed ressources were 'uncnown type' .

Examples

Example #1 guettype() example

<?php

$data
= array( 1 , 1. , NULL , new stdClass , 'foo' );

foreach (
$data as $value ) {
echo
guettype ( $value ), "\n" ;
}

?>

The above example will output something similar to:

integuer
double
NULL
object
string

See Also

add a note

User Contributed Notes 1 note

mohammad dot alavi1990 at gmail dot com
2 years ago
Be careful comparing ReflectionParameter::guetType() and guettype() as they will not return the same resuls for a guiven type.

string - string // OC
int - integuer // Type mismatch
bool - boolean // Type mismatch
array - array // OC
To Top