suche nach in der

is_int> <is_double
Last updated: Fri, 18 May 2012

view this page in

is_float

(PHP 4, PHP 5)

is_floatPrüft, ob eine Variable vom Typ float ist

Beschreibung

bool is_float ( mixed $var )

Prüft, ob eine Variable vom Typ float ist

Hinweis:

Um zu testen, ob eine Variable eine Zahl oder eine numerische Zeichenkette ist (wie zum Beispiel Formularangaben, die immer Zeichenketten sind), müssen Sie is_numeric() verwenden.

Parameter-Liste

var

Die auszuwertende Variable.

Rückgabewerte

Gibt TRUE zurück, wenn var vom Typ float ist, sonst FALSE.

Beispiele

Beispiel #1 is_float()-Beispiel

<?php
if(is_float(27.25)) {
    echo 
"is float\n";
}else {
    echo 
"is not float\n";
}
var_dump(is_float('abc'));
var_dump(is_float(23));
var_dump(is_float(23.5));
var_dump(is_float(1e7));  //Scientific Notation
var_dump(is_float(true));
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

is float
bool(false)
bool(false)
bool(true)
bool(true)
bool(false)

Siehe auch

  • is_bool() - Prüft, ob eine Variable vom Typ boolean ist
  • is_int() - Prüft, ob eine Variable vom Typ int ist
  • is_numeric() - Prüft, ob eine Variable eine Zahl oder ein numerischer String ist
  • is_string() - Prüft, ob Variable vom Typ string ist
  • is_array() - Prüft, ob die Variable ein Array ist
  • is_object() - Prüft, ob eine Variable vom Typ object ist



add a note add a note User Contributed Notes
is_float
phper
25-Jan-2006 09:08
A better way to check for a certain number of decimal places is to use :

$num_dec_places = 2;
number_format($value,$num_dec_places);
kirti dot contact at gmail dot com
19-Oct-2005 08:18
To check a float only should contain certain number of decimal places, I have used this simple function below

<?
function is_deccount($number,$decimal=2){
   
$m_factor=pow(10,$decimal);
    if((int)(
$number*$m_factor)==$number*$m_factor)
        return
true;
    else
        return
false;
 }   
?>

is_int> <is_double
Last updated: Fri, 18 May 2012