(PHP 7, PHP 8)
The SplFloat class is used to enforce strong typing of the float type.
SplFloat extends SplType {
/* Constants */
public const float __default = 0.0;
/* Methods */
public function __construct ([ float $initial_value = 0.0 ])
final public function &__invoke(): float
}
SplFloat::__default
<?php
$float = new SplFloat(3.154);
$newFloat = new SplFloat(3);
echo $float . PHP_EOL;
echo $newFloat . PHP_EOL;
The above example will output:
3.154 3
- SplType::__construct — Creates a new value of some type
- SplFloat::__invoke — Invoke object like a method