3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Abc { public $a = 1; protected $b = 2; private $c = 3; } $resource = tmpfile(); echo "\nbool:\n"; var_dump((bool) null); var_dump((bool) false); var_dump((bool) true); var_dump((bool) 123); var_dump((bool) 123.456); var_dump((bool) ''); var_dump((bool) '123'); var_dump((bool) '123abc'); var_dump((bool) 'abc123'); var_dump((bool) array()); var_dump((bool) array(null)); var_dump((bool) array(123)); var_dump((bool) array(1, 2, 3)); var_dump((bool) new StdClass()); var_dump((bool) new Abc()); var_dump((bool) $resource); echo "\nint:\n"; var_dump((int) null); var_dump((int) false); var_dump((int) true); var_dump((int) 123); var_dump((int) 123.456); var_dump((int) ''); var_dump((int) '123'); var_dump((int) '123abc'); var_dump((int) 'abc123'); var_dump((int) array()); var_dump((int) array(null)); var_dump((int) array(123)); var_dump((int) array(1, 2, 3)); var_dump((int) new StdClass()); var_dump((int) new Abc()); var_dump((int) $resource); echo "\nfloat:\n"; var_dump((float) null); var_dump((float) false); var_dump((float) true); var_dump((float) 123); var_dump((float) 123.456); var_dump((float) ''); var_dump((float) '123'); var_dump((float) '123abc'); var_dump((float) 'abc123'); var_dump((float) array()); var_dump((float) array(null)); var_dump((float) array(123)); var_dump((float) array(1, 2, 3)); var_dump((float) new StdClass()); var_dump((float) new Abc()); var_dump((float) $resource); echo "\nstring:\n"; var_dump((string) null); var_dump((string) false); var_dump((string) true); var_dump((string) 123); var_dump((string) 123.456); var_dump((string) ''); var_dump((string) '123'); var_dump((string) '123abc'); var_dump((string) 'abc123'); var_dump((string) array()); var_dump((string) array(null)); var_dump((string) array(123)); var_dump((string) array(1, 2, 3)); //var_dump((string) new StdClass()); //var_dump((string) new Abc()); var_dump((string) $resource); echo "\narray:\n"; var_dump((array) null); var_dump((array) false); var_dump((array) true); var_dump((array) 123); var_dump((array) 123.456); var_dump((array) ''); var_dump((array) '123'); var_dump((array) '123abc'); var_dump((array) 'abc123'); var_dump((array) array()); var_dump((array) array(null)); var_dump((array) array(123)); var_dump((array) array(1, 2, 3)); var_dump((array) new StdClass()); var_dump((array) new Abc()); var_dump((array) $resource); echo "\nobject:\n"; var_dump((object) null); var_dump((object) false); var_dump((object) true); var_dump((object) 123); var_dump((object) 123.456); var_dump((object) ''); var_dump((object) '123'); var_dump((object) '123abc'); var_dump((object) 'abc123'); var_dump((object) array()); var_dump((object) array(null)); var_dump((object) array(123)); var_dump((object) array(1, 2, 3)); var_dump((object) new StdClass()); var_dump((object) new Abc()); var_dump((object) $resource);
based on DTCEC
Output for 7.0.0 - 7.1.0
bool: bool(false) bool(false) bool(true) bool(true) bool(true) bool(false) bool(true) bool(true) bool(true) bool(false) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) int: int(0) int(0) int(1) int(123) int(123) int(0) int(123) int(123) int(0) int(0) int(1) int(1) int(1) Notice: Object of class stdClass could not be converted to int in /in/UDqjR on line 43 int(1) Notice: Object of class Abc could not be converted to int in /in/UDqjR on line 44 int(1) int(4) float: float(0) float(0) float(1) float(123) float(123.456) float(0) float(123) float(123) float(0) float(0) float(1) float(1) float(1) Notice: Object of class stdClass could not be converted to float in /in/UDqjR on line 61 float(1) Notice: Object of class Abc could not be converted to float in /in/UDqjR on line 62 float(1) float(4) string: string(0) "" string(0) "" string(1) "1" string(3) "123" string(7) "123.456" string(0) "" string(3) "123" string(6) "123abc" string(6) "abc123" Notice: Array to string conversion in /in/UDqjR on line 75 string(5) "Array" Notice: Array to string conversion in /in/UDqjR on line 76 string(5) "Array" Notice: Array to string conversion in /in/UDqjR on line 77 string(5) "Array" Notice: Array to string conversion in /in/UDqjR on line 78 string(5) "Array" string(14) "Resource id #4" array: array(0) { } array(1) { [0]=> bool(false) } array(1) { [0]=> bool(true) } array(1) { [0]=> int(123) } array(1) { [0]=> float(123.456) } array(1) { [0]=> string(0) "" } array(1) { [0]=> string(3) "123" } array(1) { [0]=> string(6) "123abc" } array(1) { [0]=> string(6) "abc123" } array(0) { } array(1) { [0]=> NULL } array(1) { [0]=> int(123) } array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } array(0) { } array(3) { ["a"]=> int(1) ["*b"]=> int(2) ["Abcc"]=> int(3) } array(1) { [0]=> resource(4) of type (stream) } object: object(stdClass)#1 (0) { } object(stdClass)#1 (1) { ["scalar"]=> bool(false) } object(stdClass)#1 (1) { ["scalar"]=> bool(true) } object(stdClass)#1 (1) { ["scalar"]=> int(123) } object(stdClass)#1 (1) { ["scalar"]=> float(123.456) } object(stdClass)#1 (1) { ["scalar"]=> string(0) "" } object(stdClass)#1 (1) { ["scalar"]=> string(3) "123" } object(stdClass)#1 (1) { ["scalar"]=> string(6) "123abc" } object(stdClass)#1 (1) { ["scalar"]=> string(6) "abc123" } object(stdClass)#1 (0) { } object(stdClass)#1 (1) { [0]=> NULL } object(stdClass)#1 (1) { [0]=> int(123) } object(stdClass)#1 (3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } object(stdClass)#1 (0) { } object(Abc)#1 (3) { ["a"]=> int(1) ["b":protected]=> int(2) ["c":"Abc":private]=> int(3) } object(stdClass)#1 (1) { ["scalar"]=> resource(4) of type (stream) }
Output for hhvm-3.10.0 - 3.12.0
bool: bool(false) bool(false) bool(true) bool(true) bool(true) bool(false) bool(true) bool(true) bool(true) bool(false) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) int: int(0) int(0) int(1) int(123) int(123) int(0) int(123) int(123) int(0) int(0) int(1) int(1) int(1) Notice: Object of class stdClass could not be converted to int in /in/UDqjR on line 43 int(1) Notice: Object of class Abc could not be converted to int in /in/UDqjR on line 44 int(1) int(4) float: float(0) float(0) float(1) float(123) float(123.456) float(0) float(123) float(123) float(0) float(0) float(1) float(1) float(1) Notice: Object of class stdClass could not be converted to int in /in/UDqjR on line 61 float(1) Notice: Object of class Abc could not be converted to int in /in/UDqjR on line 62 float(1) float(4) string: string(0) "" string(0) "" string(1) "1" string(3) "123" string(7) "123.456" string(0) "" string(3) "123" string(6) "123abc" string(6) "abc123" Notice: Array to string conversion in /in/UDqjR on line 75 string(5) "Array" Notice: Array to string conversion in /in/UDqjR on line 76 string(5) "Array" Notice: Array to string conversion in /in/UDqjR on line 77 string(5) "Array" Notice: Array to string conversion in /in/UDqjR on line 78 string(5) "Array" string(14) "Resource id #4" array: array(0) { } array(1) { [0]=> bool(false) } array(1) { [0]=> bool(true) } array(1) { [0]=> int(123) } array(1) { [0]=> float(123.456) } array(1) { [0]=> string(0) "" } array(1) { [0]=> string(3) "123" } array(1) { [0]=> string(6) "123abc" } array(1) { [0]=> string(6) "abc123" } array(0) { } array(1) { [0]=> NULL } array(1) { [0]=> int(123) } array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } array(0) { } array(3) { ["a"]=> int(1) ["*b"]=> int(2) ["Abcc"]=> int(3) } array(1) { [0]=> resource(4) of type (stream) } object: object(stdClass)#1 (0) { } object(stdClass)#1 (1) { ["scalar"]=> bool(false) } object(stdClass)#1 (1) { ["scalar"]=> bool(true) } object(stdClass)#1 (1) { ["scalar"]=> int(123) } object(stdClass)#1 (1) { ["scalar"]=> float(123.456) } object(stdClass)#1 (1) { ["scalar"]=> string(0) "" } object(stdClass)#1 (1) { ["scalar"]=> string(3) "123" } object(stdClass)#1 (1) { ["scalar"]=> string(6) "123abc" } object(stdClass)#1 (1) { ["scalar"]=> string(6) "abc123" } object(stdClass)#1 (0) { } object(stdClass)#1 (1) { [0]=> NULL } object(stdClass)#1 (1) { [0]=> int(123) } object(stdClass)#1 (3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } object(stdClass)#1 (0) { } object(Abc)#1 (3) { ["a"]=> int(1) ["b":protected]=> int(2) ["c":"Abc":private]=> int(3) } object(stdClass)#1 (1) { ["scalar"]=> resource(4) of type (stream) }
Output for 5.4.0 - 5.6.25
bool: bool(false) bool(false) bool(true) bool(true) bool(true) bool(false) bool(true) bool(true) bool(true) bool(false) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) int: int(0) int(0) int(1) int(123) int(123) int(0) int(123) int(123) int(0) int(0) int(1) int(1) int(1) Notice: Object of class stdClass could not be converted to int in /in/UDqjR on line 43 int(1) Notice: Object of class Abc could not be converted to int in /in/UDqjR on line 44 int(1) int(4) float: float(0) float(0) float(1) float(123) float(123.456) float(0) float(123) float(123) float(0) float(0) float(1) float(1) float(1) Notice: Object of class stdClass could not be converted to double in /in/UDqjR on line 61 float(1) Notice: Object of class Abc could not be converted to double in /in/UDqjR on line 62 float(1) float(4) string: string(0) "" string(0) "" string(1) "1" string(3) "123" string(7) "123.456" string(0) "" string(3) "123" string(6) "123abc" string(6) "abc123" Notice: Array to string conversion in /in/UDqjR on line 75 string(5) "Array" Notice: Array to string conversion in /in/UDqjR on line 76 string(5) "Array" Notice: Array to string conversion in /in/UDqjR on line 77 string(5) "Array" Notice: Array to string conversion in /in/UDqjR on line 78 string(5) "Array" string(14) "Resource id #4" array: array(0) { } array(1) { [0]=> bool(false) } array(1) { [0]=> bool(true) } array(1) { [0]=> int(123) } array(1) { [0]=> float(123.456) } array(1) { [0]=> string(0) "" } array(1) { [0]=> string(3) "123" } array(1) { [0]=> string(6) "123abc" } array(1) { [0]=> string(6) "abc123" } array(0) { } array(1) { [0]=> NULL } array(1) { [0]=> int(123) } array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } array(0) { } array(3) { ["a"]=> int(1) ["*b"]=> int(2) ["Abcc"]=> int(3) } array(1) { [0]=> resource(4) of type (stream) } object: object(stdClass)#1 (0) { } object(stdClass)#1 (1) { ["scalar"]=> bool(false) } object(stdClass)#1 (1) { ["scalar"]=> bool(true) } object(stdClass)#1 (1) { ["scalar"]=> int(123) } object(stdClass)#1 (1) { ["scalar"]=> float(123.456) } object(stdClass)#1 (1) { ["scalar"]=> string(0) "" } object(stdClass)#1 (1) { ["scalar"]=> string(3) "123" } object(stdClass)#1 (1) { ["scalar"]=> string(6) "123abc" } object(stdClass)#1 (1) { ["scalar"]=> string(6) "abc123" } object(stdClass)#1 (0) { } object(stdClass)#1 (1) { [0]=> NULL } object(stdClass)#1 (1) { [0]=> int(123) } object(stdClass)#1 (3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } object(stdClass)#1 (0) { } object(Abc)#1 (3) { ["a"]=> int(1) ["b":protected]=> int(2) ["c":"Abc":private]=> int(3) } object(stdClass)#1 (1) { ["scalar"]=> resource(4) of type (stream) }