(PHP 7, PHP 8)
The SplString class is used to enforce strong typing of the string type.
SplString extends SplType {
/* Constants */
public const string __default = '';
/* Methods */
public function __construct ([ string $initial_value = '' ])
final public function &__invoke(): string
}
SplString::__default
<?php
$string = new SplString("Testing");
var_dump($string);
echo $string; // Outputs "Testing"
The above example will output:
object(SplString)#1 (1) { ["__default"] => string(7) "Testing" } Testing
- SplType::__construct — Creates a new value of some type
- SplString::__invoke — Invoke object like a method