3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
int(299666) bool(true) Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/qEaq6 on line 6 bool(true) float(0.1) bool(true) Deprecated: ctype_digit(): Argument of type float will be interpreted as string in the future in /in/qEaq6 on line 10 bool(false) int(-1) bool(true) Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/qEaq6 on line 15 bool(false) Fatal error: Uncaught Error: Undefined constant "a" in /in/qEaq6:17 Stack trace: #0 {main} thrown in /in/qEaq6 on line 17
Process exited with code 255.
Output for 8.0.0 - 8.0.30
int(299666) bool(true) bool(true) float(0.1) bool(true) bool(false) int(-1) bool(true) bool(false) Fatal error: Uncaught Error: Undefined constant "a" in /in/qEaq6:17 Stack trace: #0 {main} thrown in /in/qEaq6 on line 17
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33
int(299666) bool(true) bool(true) float(0.1) bool(true) bool(false) int(-1) bool(true) bool(false) Warning: Use of undefined constant a - assumed 'a' (this will throw an Error in a future version of PHP) 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 4.4.1 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20
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 4.3.10 - 4.3.11, 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.

preferences:
199.79 ms | 402 KiB | 315 Q