Home > Article > Backend Development > How to convert variable to string in php
How to convert variables into strings in php: You can use the built-in function strval() to perform conversion, such as [strval(123);]. The strval() function is used to obtain the string value of a specified variable.
#strval() function is used to get the string value of a variable.
Video tutorial sharing: php video tutorial
Syntax:
string strval ( mixed $var )
Parameter description:
$var: can be any scalar Type, but cannot be an array or object.
Example:
<?php $int_str= 123; var_dump($int_str); $str = strval(123); var_dump($str); ?>
Output result:
int(123) string(3) "123"
Related recommendations: php training
The above is the detailed content of How to convert variable to string in php. For more information, please follow other related articles on the PHP Chinese website!