CKTIS / PHP
get_debug_type()
Vrátí název typu v zápisu PHP pro diagnostiku.
Verze: PHP 8.4; repository runtime, production runtime not attested
Syntaxe
get_debug_type(mixed $value): stringVrátí název typu v zápisu PHP pro diagnostiku. U objektu uvede třídu, u otevřeného prostředku druh v závorkách. Zavřený proud má vlastní označení. Název třídy platí pro pojmenované třídy. Anonymní třída obdrží diagnostické označení jako class@anonymous či stdClass@anonymous odlišné od get_class.
Signatura
get_debug_type(mixed $value): string
Výstup příkladu
["int","stdClass","resource (stream)","resource (closed)","class@anonymous","stdClass@anonymous"]
Příklady
<?php
$stream = fopen("php://memory","r");
$types = [get_debug_type(1), get_debug_type(new stdClass()), get_debug_type($stream)];
fclose($stream); $types[] = get_debug_type($stream);
$types[] = get_debug_type(new class {});
$types[] = get_debug_type(new class extends stdClass {});
echo json_encode($types);
Výsledek
["int","stdClass","resource (stream)","resource (closed)","class@anonymous","stdClass@anonymous"]