CKTIS / PHP
is_string()
Rozpozná reťazec, aj keď je prázdny, binárny alebo obsahuje iba číslice.
Verzia: PHP 8.4; repository runtime, production runtime not attested
Syntax
is_string(mixed $value): boolRozpozná reťazec, aj keď je prázdny, binárny alebo obsahuje iba číslice. Objekt s __toString dá false. Test sa hodí pred operáciou očakávajúcou priamo uložené bajty.
Signatúra
is_string(mixed $value): bool
Výstup príkladu
[true,true,true,false,false]
Príklady
<?php
class Label { public function __toString(): string { return "12"; } }
echo json_encode(array_map("is_string", ["", "\0", "12", 12, new Label()]));
Výsledok
[true,true,true,false,false]