PHP strval() function
In this chapter you will learn:
- Description for PHP strval() function
- Syntax for PHP strval() function
- Parameter for PHP strval() function
- Return value for PHP strval() function
- Example - Convert class to a string
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// ja v a 2s .com
class StrValTest
{
public function __toString()
{
return __CLASS__;
}
}
// Prints 'StrValTest'
echo strval(new StrValTest);
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP checkdate() Function
- Syntax for PHP checkdate() Function
- Parameter for PHP checkdate() Function
- Return value from PHP checkdate() Function
- Example - validate a Gregorian date
Home » PHP Tutorial » PHP Data Type Functions