SPL Type HandlingTable of Contents
The SplType classIntroductionParent class for all SPL types. Class synopsisSplType
abstract class SplType
{
/* Constants */
const
NULL
SplType::__default
= null
;
/* Methods */
__construct
([ mixed
}$initial_value
[, bool $strict
]] )Predefined Constants
The SplInt classIntroductionThe SplInt class is used to enforce strong typing of the integer type. Class synopsisSplInt
class SplInt
extends
SplType
{
/* Constants */
const
integer
SplInt::__default
= 0
;
/* Inherited methods */
SplType::__construct
([ mixed
}$initial_value
[, bool $strict
]] )Predefined Constants
Examples
Example #1 SplInt usage example
<?php The above example will output: Value not an integer 94 The SplFloat classIntroductionThe SplFloat class is used to enforce strong typing of the float type. Class synopsisSplFloat
class SplFloat
extends
SplType
{
/* Constants */
const
float
SplFloat::__default
= 0
;
/* Inherited methods */
SplType::__construct
([ mixed
}$initial_value
[, bool $strict
]] )Predefined Constants
Examples
Example #2 SplFloat usage example
<?php The above example will output: Value not a float 3.154 3 The SplEnum classIntroductionSplEnum gives the ability to emulate and create enumeration objects natively in PHP. Class synopsisSplEnum
class SplEnum
extends
SplType
{
/* Constants */
const
NULL
SplEnum::__default
= null
;
/* Methods */
public array getConstList
([ bool
$include_default = false
] )/* Inherited methods */
SplType::__construct
([ mixed
}$initial_value
[, bool $strict
]] )Predefined Constants
Examples
Example #3 SplEnum usage example
<?php The above example will output: 6 Value not a const in enum Month The SplBool classIntroductionThe SplBool class is used to enforce strong typing of the bool type. Class synopsisSplBool
class SplBool
extends
SplEnum
{
/* Constants */
const
boolean
SplBool::__default
= false
;
const
boolean
SplBool::false
= false
;
const
boolean
SplBool::true
= true
;
/* Inherited methods */
public array SplEnum::getConstList
([ bool
}$include_default = false
] )Predefined Constants
Examples
Example #1 SplBool usage example
<?php The above example will output: TRUE The SplString classIntroductionThe SplString class is used to enforce strong typing of the string type. Class synopsisSplString
class SplString
extends
SplType
{
/* Constants */
const
integer
SplString::__default
= 0
;
/* Inherited methods */
SplType::__construct
([ mixed
}$initial_value
[, bool $strict
]] )Predefined Constants
Examples
Example #2 SplString usage example
<?php The above example will output: Value not a string object(SplString)#1 (1) { ["__default"]=> string(7) "Testing" } Testing |