Source Code:
(back to article)
<?php $var1 = "42"; $var2 = "101010"; $var3 = "2c"; $var4 = "not a number"; echo intval($var1) . "\n"; // output: 42 echo intval($var2, 2) . "\n"; // output: 42 (binary to decimal conversion) echo intval($var3, 16) . "\n"; // output: 44 (hexadecimal to decimal conversion) echo intval($var4) . "\n"; // output: 0 (cannot convert "not a number" to an integer) ?>
Result:
Report an issue