strval
Converts a value to a string.
Syntax
strval(mixed $value): stringParameters
| Parameter | Type | Description |
|---|---|---|
| $value | mixed | A number, a boolean or an object with a `__toString()` method. |
Return value
stringThe string form of the value.
Examples
A number and booleans:
<?php
var_dump(strval(42));
var_dump(strval(true));
var_dump(strval(false));Output:
string(2) "42"
string(1) "1"
string(0) ""Notes
true becomes '1', while false and null become an empty string. The (string) $value cast does the same.
See also
In the tutorial
- Data types — The main PHP data types — strings, numbers, booleans, arrays and null.