3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = 0001111222 ; var_dump($a); var_dump(is_numeric($a)); //true var_dump(ctype_digit($a)); //true $a = 0.1 ; var_dump($a); var_dump(is_numeric($a)); //true var_dump(ctype_digit($a)); //false $a = -1 ; var_dump($a); var_dump(is_numeric($a)); //true var_dump(ctype_digit($a)); //false $a = a ; var_dump($a); var_dump(is_numeric($a)); //false var_dump(ctype_digit($a)); //false var_dump(sqrt(16)); var_dump(is_int(sqrt(16))); $a = 9.45*100; var_dump($a); var_dump(intval($a)); $a = 945*1.00; var_dump($a); var_dump(intval($a)); echo "<br/>数值强制转换:"; $string="2a"; $string1=intval($string); echo '$string1的值:'.$string1.'$string2的值:';//单引号不会输出变量,将原样输出 $string2=(int)($string); echo $string2 ;
Output for 4.4.1 - 4.4.9, 5.1.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
int(299666) bool(true) bool(true) float(0.1) bool(true) bool(false) int(-1) bool(true) bool(false) Notice: Use of undefined constant a - assumed 'a' in /in/qEaq6 on line 17 string(1) "a" bool(false) bool(false) float(4) bool(false) float(945) int(944) float(945) int(945) <br/>数值强制转换:$string1的值:2$string2的值:2
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.3.10 - 4.4.0, 5.0.3 - 5.0.5
int(299666) bool(true) bool(true) NULL NULL NULL int(-1) bool(true) bool(false) Notice: Use of undefined constant a - assumed 'a' in /in/qEaq6 on line 17 NULL NULL NULL float(4) bool(false) NULL NULL float(945) int(945) <br/>数值强制转换:$string1的值:$$string2的值:2
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.2
int(299666) bool(true)
Process exited with code 139.