3v4l.org

run code in 300+ PHP versions simultaneously
<?php class HelloWorld { public function sayInt($mixed): void { if (ctype_digit((int) $mixed)) { var_dump($mixed); } } public function sayString($mixed): void { if (ctype_digit((string) $mixed)) { var_dump($mixed); } } public function sayBool($mixed): void { if (ctype_digit((bool) $mixed)) { var_dump($mixed); } } } echo "\n\nsayInt\n\n"; $h = new HelloWorld(); $h->sayInt(1); $h->sayInt(0); $h->sayInt(-1); $h->sayInt(true); $h->sayInt(false); $h->sayInt([]); $h->sayInt([1]); $h->sayInt([false]); $h->sayInt(1.1); $h->sayInt('0123'); $h->sayInt('123'); $h->sayInt('a123'); $h->sayInt('123a'); $h->sayInt('abc'); $h->sayInt('1<'); echo "\n\nsayString\n\n"; $h = new HelloWorld(); $h->sayString(1); $h->sayString(0); $h->sayString(-1); $h->sayString(true); $h->sayString(false); $h->sayString([]); $h->sayString([1]); $h->sayString([false]); $h->sayString(1.1); $h->sayString('0123'); $h->sayString('123'); $h->sayString('a123'); $h->sayString('123a'); $h->sayString('abc'); $h->sayString('1<'); echo "\n\nsayBool\n\n"; $h = new HelloWorld(); $h->sayBool(1); $h->sayBool(0); $h->sayBool(-1); $h->sayBool(true); $h->sayBool(false); $h->sayBool([]); $h->sayBool([1]); $h->sayBool([false]); $h->sayBool(1.1); $h->sayBool('0123'); $h->sayBool('123'); $h->sayBool('a123'); $h->sayBool('123a'); $h->sayBool('abc'); $h->sayBool('1<');
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
sayInt Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/k3Qce on line 7 Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/k3Qce on line 7 Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/k3Qce on line 7 Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/k3Qce on line 7 Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/k3Qce on line 7 Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/k3Qce on line 7 Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/k3Qce on line 7 Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/k3Qce on line 7 Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/k3Qce on line 7 Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/k3Qce on line 7 Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/k3Qce on line 7 Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/k3Qce on line 7 Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/k3Qce on line 7 Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/k3Qce on line 7 Deprecated: ctype_digit(): Argument of type int will be interpreted as string in the future in /in/k3Qce on line 7 sayString int(1) int(0) bool(true) Warning: Array to string conversion in /in/k3Qce on line 14 Warning: Array to string conversion in /in/k3Qce on line 14 Warning: Array to string conversion in /in/k3Qce on line 14 string(4) "0123" string(3) "123" sayBool Deprecated: ctype_digit(): Argument of type bool will be interpreted as string in the future in /in/k3Qce on line 21 Deprecated: ctype_digit(): Argument of type bool will be interpreted as string in the future in /in/k3Qce on line 21 Deprecated: ctype_digit(): Argument of type bool will be interpreted as string in the future in /in/k3Qce on line 21 Deprecated: ctype_digit(): Argument of type bool will be interpreted as string in the future in /in/k3Qce on line 21 Deprecated: ctype_digit(): Argument of type bool will be interpreted as string in the future in /in/k3Qce on line 21 Deprecated: ctype_digit(): Argument of type bool will be interpreted as string in the future in /in/k3Qce on line 21 Deprecated: ctype_digit(): Argument of type bool will be interpreted as string in the future in /in/k3Qce on line 21 Deprecated: ctype_digit(): Argument of type bool will be interpreted as string in the future in /in/k3Qce on line 21 Deprecated: ctype_digit(): Argument of type bool will be interpreted as string in the future in /in/k3Qce on line 21 Deprecated: ctype_digit(): Argument of type bool will be interpreted as string in the future in /in/k3Qce on line 21 Deprecated: ctype_digit(): Argument of type bool will be interpreted as string in the future in /in/k3Qce on line 21 Deprecated: ctype_digit(): Argument of type bool will be interpreted as string in the future in /in/k3Qce on line 21 Deprecated: ctype_digit(): Argument of type bool will be interpreted as string in the future in /in/k3Qce on line 21 Deprecated: ctype_digit(): Argument of type bool will be interpreted as string in the future in /in/k3Qce on line 21 Deprecated: ctype_digit(): Argument of type bool will be interpreted as string in the future in /in/k3Qce on line 21
Output for 8.0.1 - 8.0.30
sayInt sayString int(1) int(0) bool(true) Warning: Array to string conversion in /in/k3Qce on line 14 Warning: Array to string conversion in /in/k3Qce on line 14 Warning: Array to string conversion in /in/k3Qce on line 14 string(4) "0123" string(3) "123" sayBool

preferences:
123.51 ms | 402 KiB | 91 Q