Fonction floatval()
Exemple
Retourne la valeur flottante de différentes variables :
<?php
$a = "1234.56789";
echo floatval($a) . "<br>";
$b = "1234.56789Hello";
echo floatval($b) . "<br>";
$c = "Hello1234.56789";
echo floatval($c) . "<br>";
?> Définition et utilisation
La fonction floatval() retourne la valeur flottante d'une variable.
Syntaxe
floatval( variable ); Valeurs des paramètres
| Paramètre | Description |
|---|---|
| variable | Requis. Spécifie la variable à vérifier. Doit être de type scalaire. |
Détails techniques
| Valeur de retour : | La valeur flottante de la variable en cas de succès, 0 en cas d'échec. Un tableau vide retournera 0, et un tableau non vide retournera 1. |
|---|---|
| Type de retour : | Flottant |
| Version PHP : | 4.2+ |