Recently, due to my Java class, I’ve been typing parseInt() in my PHP code instead of intval().

Here is a compilation of all sorts of ways to parse string into integers:

PHP

var $num = intval("0001");

JavaScript/ActionScript

var num = parseInt("0001", 10);

Java

int num = Integer.parseInt("0001");

Apparently you need to type really long to parse stuff in Java.

Python

num = int("0001")

Ruby

num = "0001".to_i
comments powered by Disqus