You don’t typically need to do this, since PHP will coerce the type for you in most circumstances. For situations where you do want to explicitly convert the type, cast it:
$num = "3.14";
$int = (int)$num;
$float = (float)$num;
More Related Contents:
- Converting an integer to a string in PHP
- PHP unexpected result of float to int type cast
- Convert a big integer to a full string in PHP
- How to convert an array to object in PHP?
- Comparing String to Integer gives strange results
- How create an array from the output of an array printed with print_r?
- Fastest way to convert string to integer in PHP
- How to convert string to boolean php
- How to Cast Objects in PHP
- Casting an Array with Numeric Keys as an Object
- PHP String to Float
- Type casting for user defined objects
- Cakephp-3.x: How to change the data type of a selected alias?
- Why does PHP convert a string with the letter E into a number?
- Cast the current object ($this) to a descendent class
- How to cast array elements to strings in PHP?
- make switch use === comparison not == comparison In PHP
- Array to Object and Object to Array in PHP – interesting behaviour
- Dynamically create PHP object based on string
- How to cast variable to array
- PHP typecasting
- HTTPS and SSL3_GET_SERVER_CERTIFICATE:certificate verify failed, CA is OK
- POST an array from an HTML form without javascript [duplicate]
- What’s the best way to get the last element of an array without deleting it?
- PHPMailer GoDaddy Server SMTP Connection Refused
- Search for a key in an array, recursively
- Creating a config file in PHP
- Understanding nested PHP ternary operator [duplicate]
- PDO + MySQL and broken UTF-8 encoding
- permission denied – php unlink