NOVINKA: Najžiadanejšie rekvalifikačné kurzy teraz s 50% zľavou + kurz AI ZADARMO. Nečakaj, táto ponuka dlho nevydrží! Zisti viac:

PHP - is_numeric

Trieda

Koreň \ Bez triedy

Metóda - is_numeric

(PHP 4, PHP 5, PHP 7)

Determines whether a given variable is a number. The number can also be represented by a string containing numeric value, but not in the hexadecimal or binary notations. The scientific notation (the "e" character) is supported.

Procedurálne

Parametre

NázovDátový typPredvolená hodnotaPopis
$varmixed

The variable being checked.

Mávratovej hodnoty

Vracia: bool

Returns true if the variable is a number or a string containing a numeric value, returns false otherwise.

Príklady

<?php

echo is_numeric("42") ? "'42' is a number.\n" : "'42' is not a number.\n";
echo is_numeric(42) ? "42 is a number.\n" : "42 is not a number.\n";
echo is_numeric("hi") ? "'hi is a number.\n" : "'hi is not a number.\n";
echo is_numeric(array()) ? "array() is a number.\n" : "array() is not a number.\n";
echo is_numeric(1212e2) ? "1212e2 is a number.\n" : "1212e2 is not a number.\n";

Súvisiace manuály

      Aktivity