php method to convert variables into strings: use the built-in function strval(), the syntax is "strval (var)", where var can be any scalar type; the strval() function can get the string of the variable value and returned, but cannot be used for arrays or objects.
There is a built-in function strval() in php, which is used to get the string value of a variable and return it.
(Recommended tutorial: php video tutorial)
Function syntax:
string strval ( mixed $var )
Note: var can be any scalar type. You cannot use strval() with arrays or objects.
Code example:
<?php $foo = strval(123); var_dump($foo); ?>
(Related recommendations: php training)
Output result:
string(3) "123"
The above is the detailed content of How to convert variable into string in php. For more information, please follow other related articles on the PHP Chinese website!