(PECL spl_types >= 0.1.0)
SplString::__construct — Construit un objet de type chaîne
Construit un objet de type chaîne.
Le paramètre input accepte une chaîne de caractères Une exception UnexpectedValueException est émise si un problème survient.
Aucune valeur n'est retournée.
Exemple #1 Exemple avec SplString::__construct()
<?php
$string = new SplString("Test");
try {
$string = array();
} catch (UnexpectedValueException $uve) {
echo $uve->getMessage() . PHP_EOL;
}
var_dump($string);
echo $string; // Outputs "Test"
?>
L'exemple ci-dessus va afficher :
Value not a string object(SplString)#1 (1) { ["__default"]=> string(7) "Test" } Testing