Manuel PHP

SplEnum::__construct

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

SplEnum::__constructConstructs an enumeger object type

Description

SplEnum::__construct ( void )

This constructor is used to set the value and the strictness of the "Enum" Object.

Liste de paramètres

input

The input parameter accepts an integer and will throw an UnexpectedValueException if anything else is passed.

strict

A boolean variable to indicate wether the object's strictness should be set or not.

Valeurs de retour

Aucune valeur n'est retournée.

Exemples

Exemple #1 SplEnum::__construct() example

  1. <?php
  2.  
  3. class EnumOne extends SplEnum  
  4. { 
  5.    const __default = 1;  
  6. }  
  7.  
  8. class EnumTwo extends SplEnum  
  9. { 
  10.    const __default = 2;  
  11. }  
  12.  
  13. class EnumThree extends SplEnum  
  14. { 
  15.    const __default = 3;  
  16. }  
  17.  
  18. $enumOne = new EnumOne();  
  19. $enumTwo = new EnumTwo();  
  20. $enumThree = new EnumThree();  
  21.  
  22.  
  23. echo 'Enum one : ' . $enumOne . PHP_EOL;  
  24. echo 'Enum two : ' . $enumTwo . PHP_EOL;  
  25. echo 'Enum three: ' . $enumThree . PHP_EOL;  
  26. ?> 

L'exemple ci-dessus va afficher :

Enum one : 1 Enum two : 2 Enum three: 3


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