String Coercion
Cast passed value into a PHP string type.
The StringTypeCoercer takes one optional floatPrecision parameter.
This parameter responsible for maximum precision when converting from float to string. If the value is not specified (null), then the precision corresponds to the value of precision in php.ini.
Input Value | Output Result | Description |
|---|---|---|
|
| Returns the string value "as is" |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| Converts float to a string value [1] |
|
| Converts int to a string value [2] |
|
| Converts object to a string value [3] |
|
| Converts resource to a string value [4] |
|
| Returns the value of the backed enum's case |
|
| Returns the name of the unit enum's case |
Other |
| Throws |
Notes
The float-to-string casting uses built-in PHP rules:
The float value accuracy depends on the
precisionvalue inphp.inifile.If a loss of precision occurs during conversion to a string, an
InvalidValueExceptionerror will occur.
The int-to-string casting uses built-in PHP rules.
For objects implementing the
Stringableinterface, the__toString()method will be called.Returns the resource name, such as
"stream"for file streams. If the resource is unknown, then simply the string"resource"will be returned.