Skip to content
Advertisement

Integer value returns 0 after trying to convert it from string

I have variable like this with the type of string:

JavaScript

Now I tried setting it’s type to integer, so I tried these:

JavaScript

So how to properly return the value 65000 as integer?

Advertisement

Answer

You wrong code, the first it’s correct and the second is intval($variable)

JavaScript

I hope it’s just a typing error but in the variable you didn’t close with ;


Another method you can use is settype like:

JavaScript

Reference:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement