CKTIS / PHP
get_debug_type()
Vráti názov typu v zápise PHP pre diagnostiku.
Verzia: PHP 8.4; repository runtime, production runtime not attested
Syntax
get_debug_type(mixed $value): stringVráti názov typu v zápise PHP pre diagnostiku. Pri objekte uvedie triedu, pri otvorenom prostriedku druh v zátvorkách. Zatvorený prúd má osobitné označenie. Názov triedy platí pre pomenované triedy. Anonymná trieda dostane diagnostické označenie ako class@anonymous či stdClass@anonymous odlišné od get_class.
Signatúra
get_debug_type(mixed $value): string
Výstup príkladu
["int","stdClass","resource (stream)","resource (closed)","class@anonymous","stdClass@anonymous"]
Prí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ýsledok
["int","stdClass","resource (stream)","resource (closed)","class@anonymous","stdClass@anonymous"]