Home > Article > Backend Development > How to convert int to string type in php
php method to convert int to string type: You can use the built-in function strval() to convert, the syntax is "strval (int type value)"; the strval() function can get the string value of the specified variable . It should be noted that the strval() function cannot be used for arrays or objects.
php provides us with a built-in function strval(), which can get the string value of a variable.
(Recommended tutorial: php video tutorial)
Syntax:
string strval ( mixed $var )
Return value:
The function returns the string value of var .
Note: var can be any scalar type. You cannot use strval() with arrays or objects.
(Related recommendations: php training)
Example:
<?php $foo = strval(123); var_dump($foo); ?>
Result:
string(3) "123"
The above is the detailed content of How to convert int to string type in php. For more information, please follow other related articles on the PHP Chinese website!