Get the string value of a variable.
PHP strval() function has the following syntax.
string strval ( mixed $var )
The string value of var.
Convert class to a string
<?php/* ww w.j a v a 2 s . c o m*/
class StrValTest
{
public function __toString()
{
return __CLASS__;
}
}
// Prints 'StrValTest'
echo strval(new StrValTest);
?>
The code above generates the following result.