Example usage of strval() function in PHP


1. Function description

The strval() function is a built-in function in PHP that converts any standard value (string, integer, or double) to a string. We cannot use strval in arrays or objects. If this function is used, it only returns the type name of the value to be converted.

2. Grammar

string strval (mixed $var)

3. Parameter description

$var: can be any scalar type, but cannot be an array or object.

4. Return value

Returns a string.

5. Instance

<?php$int_str= 123;var_dump($int_str);$str = strval(123);var_dump($str);?>
int(123)string(3) "123"

Instance extension:

$int_str= 123;
$str = strval(123);

The output result is:

string(3) “123”

This is the end of this article about the instance usage of strval() function in PHP. For more information about how to use strval() function in PHP, please search the previous articles of developeppaer or continue to browse the following articles. I hope you will support developeppaer in the future!