PHP strval() function
Description
Get the string value of a variable.
Syntax
PHP strval() function has the following syntax.
string strval ( mixed $var )
Parameter
- var - The variable that is being converted to a string.
Return
The string value of var.
Example
Convert class to a string
<?php//from ww w .ja v a 2s . c om
class StrValTest
{
public function __toString()
{
return __CLASS__;
}
}
// Prints 'StrValTest'
echo strval(new StrValTest);
?>
The code above generates the following result.