Stringable¶
Stringable is a type, which represents variables that may be used as as string : either a string, a heredoc or a string constant; or an object which has the __toString() method.
Stringable is automatically added to any class (and subclass) that has the __toString() method, though it is recommended to add it explicitly.
<?php
function foo(stringable $s) {
print $s;
}
?>
See also What is Stringable Interface in PHP 8?
Related : String
Added in PHP 8.0