The function strval() gets string value of a variable.
string strval ( mixed $value )
Sr.No | Parameter | Description |
---|---|---|
1 |
value |
The variable that is being converted to a string. value may be any scalar type or an object that implements the __toString() method. You cannot use strval() on arrays or on objects that do not implement the __toString() method. |
This function returns string value of value. This function does not format the returned value.
PHP 4 and above
Following example demonstrates use of function strval():
<?php $a = "Tutorialspoint"; var_dump(strval($a)) ; echo "<br>"; $b = 40; var_dump(strval($b)); echo "<br>"; $c = NULL; var_dump(strval($c)); echo "<br>"; $d = array("a", "b", "c"); var_dump(strval($d)); //This will print only the type of value being converted i.e. 'Array' echo "<br>"; $e = ''; var_dump(strval($e)); echo "<br>"; ?>
This will produce following result −
string(14) "Tutorialspoint" string(2) "40" string(0) "" string(5) "Array" string(0) ""