Manuel PHP

SplFloat::__construct

(No version information available, might be only in CVS)

SplFloat::__constructConstructs a float object type

Description

SplFloat::__construct ( void )

This constructs a new object of type float.

Liste de paramètres

input

The input parameter accepts a float or an integer. If an integer is passed, it will be converted to float.

Valeurs de retour

Aucune valeur n'est retournée.

Exemples

Exemple #1 SplFloat::__construct() example

  1. <?php
  2. $float   = new SplFloat(3.154);  
  3. $newFloat = new SplFloat(3);  
  4.  
  5. try { 
  6.    $float = 'Try to cast a string value for fun';  
  7. } catch (UnexpectedValueException $uve) { 
  8.    echo $uve->getMessage() . PHP_EOL;  
  9. }  
  10.  
  11. var_dump($float);  
  12. var_dump($newFloat);  
  13. ?> 

L'exemple ci-dessus va afficher :

Value not a float object(SplFloat)#1 (1) { ["__default"]=> float(3.154) } object(SplFloat)#2 (1) { ["__default"]=> float(3) }


Remonter Remonter
L'éditeur javascript - CSS - Gentoo - Tutoriaux PHP - Tutoriels PHP - Bretagne - php - Moto - Kit graphique