KennisbankExamencentrum
NL · NLNederlands (Nederland)
Taal kiezen13

CKTIS / PHP

is_string()

Herkent een string ook als die leeg of binair is of uitsluitend cijfers bevat.

Versie: PHP 8.4; repository runtime, production runtime not attested

Syntax

is_string(mixed $value): bool

Herkent een string ook als die leeg of binair is of uitsluitend cijfers bevat. Een object met __toString geeft false. De controle is bruikbaar vóór een bewerking die opgeslagen bytes verwacht.

Signatuur

is_string(mixed $value): bool

Uitvoer van het voorbeeld

[true,true,true,false,false]

Voorbeelden

<?php
class Label { public function __toString(): string { return "12"; } }
echo json_encode(array_map("is_string", ["", "\0", "12", 12, new Label()]));

Resultaat

[true,true,true,false,false]

Bronnen