No, no function provides the automatic cast. However you can cast with this simple hack (the cast is automatically made by PHP in internal):

float = "1.23"+0;

for generic number:

$yourNumberCasted = $yourStringNumber + 0;

With a function:

function castToNumber($genericStringNumber) { 
    return $genericStringNumber+0; 
}
$yourNumberCasted = castToNumber($yourStringNumber);
Answer from antoox on Stack Overflow
🌐
Hhvm
docs.hhvm.com › type conversion
Type Conversion | Hack & HHVM Documentation
If an expression is converted to its own type, the type and value of the result are the same as the type and value of the expression. When an expression of type num is converted, if that expression is currently an int, then int conversion rules apply; otherwise, float conversion rules apply. When an expression of type arraykey is converted, if that expression is currently an int, then int conversion rules apply; otherwise, string ...
🌐
Hacking with Swift
hackingwithswift.com › example-code › language › how-to-convert-a-string-to-an-int
How to convert a String to an Int - free Swift example code and tips
September 19, 2019 - How to multiply an int and a double · How to convert dates and times to a string using DateFormatter · This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions. BUY OUR BOOKS · Was this page useful? Let us know! 1 · 2 · 3 · 4 · 5 · Average rating: 4.3/5 · Thank you! Click here to visit the Hacking with Swift store >> You are not logged in Log in or create account ·
Discussions

Hack: Cast of any type to int / float / string is permitted
HHVM Version HipHop VM 3.16.0-dev (rel) Compiler: heads/master-0-g6e071f9bc61705bf78cc03a34bea56187265b3ea Repo schema: 5f3c657c22fb79db502a22ee010bf3d040eff565 Standalone code, or other way to rep... More on github.com
🌐 github.com
1
November 4, 2016
php - Cast string to either int or float - Stack Overflow
I'm looking for a function that ... of the string, e.g. "1.23" -> float 1.23, "123" -> int 123. I know I can use if-s with is_int, is_float and cast to appropriate types - but maybe there is a function that would do it automatically? ... No, no function provides the automatic cast. However you can cast with this simple hack (the cast ... More on stackoverflow.com
🌐 stackoverflow.com
c# - Converting string to integer by selecting the elements to stay - Stack Overflow
I have to eliminate all special characters, alphabets and keep only the numbers in the string and store it into an integer. For example "$67%!" or "$127a%". I am obtaining data from serial port and... More on stackoverflow.com
🌐 stackoverflow.com
Converting an integer to a string in PHP - Stack Overflow
Is there a way to convert an integer to a string in PHP? More on stackoverflow.com
🌐 stackoverflow.com
🌐
HackerRank
hackerrank.com › challenges › java-int-to-string › forum
Java Int to String Discussions | Java | HackerRank
After trying to create a new variable "n" and seeing an error that it already exists, that simplified the solution to just one line of code ;) ... public static void main(String[] args) { Scanner scn = new Scanner(System.in); int n = scn.nextInt(); // Object str = "" + n; Object str = String.valueOf(n); if (str instanceof String) { System.out.println("Good job"); } else { System.out.println("Wrong answer"); } scn.close(); }
🌐
HappyCoders.eu
happycoders.eu › java › deep-reflection-how-to-hack-integer-and-string
Java Deep Reflection: How to Hack Integer and String
June 12, 2025 - In the main method, a = 2 is boxed ... unequal to 5 (unless the 5 has also been "hacked" … which, as far as I know, is not possible with an int primitive). (*This behavior is not guaranteed, but in practice, it is so. You can increase the cached integer range with -XX:AutoBoxCacheMax.) You can do the same with Strings...
🌐
Hhvm
docs.hhvm.com › hsl › reference › function › HH.Lib.Str.to_int
Str\to_int
Hack · HHVM · See Something Wrong? File an Issue · DocumentationHSLReferenceFunctionHH\Lib\Str\to_int · Meta Engineer? This is available as Str\to_int in the www repository. Returns the given string as an integer, or null if the string isn't numeric · namespace HH\Lib\Str; function to_int( string $string, ): ?int; String ·
🌐
GitHub
github.com › facebook › hhvm › issues › 7466
Hack: Cast of any type to int / float / string is permitted · Issue #7466 · facebook/hhvm
November 4, 2016 - No error from Hack, but these errors at runtime: PHP Notice: Object of class Foo could not be converted to int int(1) PHP Notice: Object of class Foo could not be converted to float double(1) PHP Catchable fatal error: Object of class Foo could not be converted to string ·
Author   facebook
Find elsewhere
🌐
Hacking with PHP
hackingwithphp.com › 3 › 4 › 0 › forcing-a-type-with-type-casting
Forcing a type with type casting – Hacking with PHP - Practical PHP
However, we type cast it to be an integer, so PHP will convert it to an integer, and place the result into · $myinteger. You can type cast as boolean using (bool), string using (string), and floating-point using (float).
🌐
Hhvm
docs.hhvm.com › hack › expressions-and-operators › casting
Expressions And Operators: Casting
Casts in Hack convert values to different types. To assert a type without changing its value, see type assertions. (float)1; // 1.0 (int)3.14; // 3, rounds towards zero (bool)0; // false (string)false; // "" Casts are only supported for bool, int, float and string.
🌐
Jazz Community Site
jazz.net › dxl › html › 938 - potential tips to avoid 64bit Memory hack to work around the int to string conversion function (.. (.html
potential tips to avoid 64bit Memory hack to work around the int to string conversion function (::.. (int, string) )
In order to be able to implement a parent and child context mechanism (https://www.ibm.com/developerworks/community/forums/html/threadTopic?id=0a1dc1ee-cd96-411e-9e19-f53899e7ffd7&ps=25) I have to consider a memory hack to make that available in a DOORS 64bit environment · Actually my development ...
🌐
Microsoft MakeCode
makecode.microbit.org › reference › text › parse-int
parse Int
But, only the integer part (left of the decimal point) is converted to a number. If the text has other characters, like "-2g5u7", only -2 is returned since it is the best attempt at converting to a number. So, try not to mix number characters with letters or other symbols. ... If the text string has the letter ‘e’ after the number characters and then some more number characters like “2e4”, then the number characters after the ‘e’ are an exponent of 10.
🌐
IBM
ibm.com › mysupport › s › question › 0D50z00006HIDWE › potential-tips-to-avoid-64bit-memory-hack-to-work-around-the-int-to-string-conversion-function-int-string-
Ibm
IBM’s technical support site for all IBM products and services including self-help and the ability to engage with IBM support engineers.
🌐
Hacking with Swift
hackingwithswift.com › example-code › language › how-to-convert-an-int-to-a-string
How to convert an Int to a String - free Swift example code and tips
June 1, 2019 - Swift's string interpolation means you can convert all sorts of data – including integers – to a string in just one line of code: ... SPONSORED Know what's happening with your apps! AppCherish connects to App Store Connect and delivers daily insights, crash alerts, and performance signals — so you stay focused on building. Use discount code “HACKINGWITHSWIFT50” at checkout to get 50% off, forever!
🌐
Grey Hack
codedocs.ghtools.xyz › data
Data Handling - Grey Hack Code Docs
Returns the unicode character (string) with code point int ... Takes a starting number, optional end (number) and optional inc (number). If inc is not defined, the increment defaults to 1 (if end > start) or otherwise to -1