How php converts Boolean types to strings
Xiaobian to share with you how php Boolean type into a string, I hope you have something to gain after reading this article, let's discuss it together!
php Methods to convert Boolean types to strings: 1. Use the strval() function, syntax "strval($bool)";2. Use the settype() function, syntax "settype($bool, 'string')".
Operating environment of this tutorial: Windows 7 system, PHP7.1 version, DELL G3 computer
Method 1: Use the strval() function
strval() function: used to get the string value of a variable.
Examples:
Effect drawing:
Method 2: Use the settype() function
settype() function: used to set the type of a variable.
The types that can be set are:
"boolean"(or "bool" as of PHP 4.2.0)
"integer"(or "int" as of PHP 4.2.0)
"float"(only available after PHP 4.2.0,"double" used in older versions is now deprecated)
"string"
"array"
"object"
"null"(since PHP 4.2.0)
Note: The settype() function changes the type of the variable itself.
Examples:
Effect drawing:
After reading this article, I believe you have a certain understanding of "how php converts boolean types into strings". If you want to know more about this knowledge, please pay attention to the industry information channel. Thank you for reading!