PHP is_string() Fonction
Exemple
Vérifiez si une variable est de type chaîne :
<?php
$a = "Hello";
echo "a est " . is_string($a) . "<br>";
$b = 0;
echo "b est " . is_string($b) . "<br>";
$c = 32;
echo "c est " . is_string($c) . "<br>";
$d = "32";
echo "d est " . is_string($d) . "<br>";
$e = true;
echo "e est " . is_string($e) . "<br>";
$f = "null";
echo "f est " . is_string($f) . "<br>";
$g = "";
echo "g est " . is_string($g) . "<br>";
?> Définition et Utilisation
La fonction is_string() vérifie si une variable est de type chaîne.
Cette fonction retourne true (1) si la variable est de type chaîne, sinon elle retourne false ou rien.
Syntaxe
is_string( variable ); Valeurs des Paramètres
| Paramètre | Description |
|---|---|
| variable | Requis. Spécifie la variable à vérifier. |
Détails Techniques
| Valeur de Retour : | TRUE si variable est une chaîne, FALSE sinon. |
|---|---|
| Type de Retour : | Booléen |
| Version PHP : | 4.0+ |