strval()
strval() — Get string value of a variable.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Get the string value of a variable. See the documentation on string for more information on converting to string.
Signature
strval(mixed $value): string
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $value | mixed | The variable that is being converted to a string. |
Return value
The string value of value.
Example
A runnable snippet:
class StrValTest { public function __toString() { return __CLASS__; } } // Prints 'StrValTest' echo strval(new StrValTest);
See also
boolval(), floatval(), intval(), settype(), sprintf(), number_format()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page strval() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.