$number = 10;
$string = 'Hello, world!';
$array = [1, 2, 3];
$object = new stdClass();

echo gettype($number); // 'integer'
echo gettype($string); // 'string'
echo gettype($array); // 'array'
echo gettype($object); // 'object'
gettype(mixed $value): string
$var1 = true;
$var2 = false;

$type1 = gettype($var1); // $type1에는 'boolean'이 저장됩니다.
$type2 = gettype($var2); // $type2에는 'boolean'이 저장됩니다.

// 주로 조건문과 논리 연산에서 사용됩니다.
if ($var1) {
    echo '$var1은 true입니다.';
} else {
    echo '$var1은 false입니다.';
}

if ($var2) {
    echo '$var2은 true입니다.';
} else {
    echo '$var2은 false입니다.';
}
$var1 = true;
$var2 = false;

// is_bool() 함수를 사용하여 변수가 불리언인지 확인합니다.
if (is_bool($var1)) {
    echo '$var1은 불리언 (boolean)입니다.';
} else {
    echo '$var1은 불리언이 아닙니다.';
}

if (is_bool($var2)) {
    echo '$var2은 불리언 (boolean)입니다.';
} else {
    echo '$var2은 불리언이 아닙니다.';
}
$num1 = 10;
$num2 = -10;
$num3 = 0;

echo gettype($num1); // 'integer'
echo gettype($num2); // 'integer'
echo gettype($num3); // 'integer'
$num1 = 10;
$num2 = -10;
$num3 = 0;

echo is_int($num1); // true
echo is_int($num2); // true
echo is_int($num3); // true
$num1 = 10.5;
$num2 = -10.5;
$num3 = 0.0;

echo gettype($num1); // 'double'
echo gettype($num2); // 'double'
echo gettype($num3); // 'double'
$num1 = 10.5;
$num2 = -10.5;
$num3 = 0.0;

echo is_float($num1); // true
echo is_float($num2); // true
echo is_float($num3); // true
$str1 = 'Hello, world!';
$str2 = '환영합니다. 반갑습니다!';
$str3 = '';

echo gettype($str1); // 'string'
echo gettype($str2); // 'string'
echo gettype($str3); // 'string'
$str1 = 'Hello, world!';
$str2 = '환영합니다. 반갑습니다!';
$str3 = '';

echo is_string($str1); // true
echo is_string($str2); // true
echo is_string($str3); // true
$arr1 = [1, 2, 3];
$arr2 = ['Hello', 'world'];
$arr3 = [];

$arr4 = [
    'name' => 'John Doe',
    'age' => 30,
];

echo gettype($arr1); // 'array'
echo gettype($arr2); // 'array'
echo gettype($arr3); // 'array'
echo gettype($arr4); // 'array'
$arr1 = [1, 2, 3];
$arr2 = ['Hello', 'world'];
$arr3 = [];

$arr4 = [
    'name' => 'John Doe',
    'age' => 30,
];

echo is_array($arr1); // true
echo is_array($arr2); // true
echo is_array($arr3); // true
echo is_array($arr4); // true
class MyClass {
    public $name = 'John Doe';
    public $age = 30;
}

$obj1 = new MyClass();
$obj2 = clone $obj1;

echo gettype($obj1); // 'object'
echo gettype($obj2); // 'object'
class MyClass {
    public $name = 'John Doe';
    public $age = 30;
}

$obj1 = new MyClass();
$obj2 = clone $obj1;

echo is_object($obj1); // true
echo is_object($obj2); // true
// 파일을 엽니다.
$fp = fopen('test.txt', 'w');

echo gettype($fp); // 'resource'
// 파일을 엽니다.
$fp = fopen('test.txt', 'w');

echo is_resource($fp); // true
// 파일을 엽니다.
$fp = fopen('test.txt', 'w');

// 파일 핸들을 닫습니다.
fclose($fp);

echo gettype($fp); // 'resource (closed)'
// 파일을 엽니다.
$fp = fopen('test.txt', 'w');

// 파일 핸들을 닫습니다.
fclose($fp);

if (gettype($fp) == 'resource (closed)') {
	echo "파일 포인터가 닫혔습니다."; // 출력
} else {
	echo '파일 포인터가 열려 있습니다.';
}
$a = null;
$b;

echo gettype($a); // 'NULL'
echo gettype($b); // 'NULL'
$a = null;
$b;

echo is_null($a); // true
echo is_null($b); // true