In this tutorial, you shall learn about Type Conversions in PHP, and how to convert a value of a type to another type, with the help of example programs.
PHP Type Conversions
In most of the cases, we can either use type casting or a built-in function to convert given value into required to data type.
The following PHP tutorials cover conversion of a give value to other datatypes.
String to other datatypes
- PHP – Convert string to integer PHP Tutorial to convert given string into integer, if the value inside string is a valid integer.
- PHP – Convert string to float PHP Tutorial to convert given string into floating point number, if the value inside string is a valid float.
- PHP – Convert string to boolean PHP Tutorial to convert string value of
"true"
or"false"
, ignoring the case, into boolean type value using string comparison.
Integer to other datatypes
- PHP – Convert integer to string PHP Tutorial to convert given integer value to a string.
- PHP – Convert integer to float PHP Tutorial to convert given string into floating point number, if the value inside string is a valid float.
- PHP – Convert integer to boolean
Float to other datatypes
- PHP – Convert float to string PHP Tutorial to convert given string into integer, if the value inside string is a valid integer.
- PHP – Convert float to int PHP Tutorial to convert given string into floating point number, if the value inside string is a valid float.
- PHP – Convert float to boolean
Boolean to other datatypes
- PHP – Convert boolean to string PHP Tutorial to convert given string into integer, if the value inside string is a valid integer.
- PHP – Convert boolean to int
- PHP – Convert boolean to float PHP Tutorial to convert given string into floating point number, if the value inside string is a valid float.