Base di conoscenzaCentro esami
ITItaliano
Scegli la lingua13

CKTIS / PHP

is_numeric()

Riconosce numeri e stringhe numeriche.

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

Sintassi

is_numeric(mixed $value): bool

Riconosce numeri e stringhe numeriche. In PHP 8 il numero può essere circondato da spazi bianchi ASCII e avere un esponente. Un testo esadecimale e un’unità dopo il numero danno false.

Firma

is_numeric(mixed $value): bool

Output dell’esempio

[true,true,false,false,true]

Esempi

<?php
echo json_encode(array_map("is_numeric", [" 2 ", "1e3", "0xff", "2kg", 3]));

Risultato

[true,true,false,false,true]

Fonti