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(); 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); 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); 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); 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); 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); 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 FHT4S
Output for 7.1.0
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(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/DTCEC on line 41 int(1) Notice: Object of class Abc could not be converted to int in /in/DTCEC on line 42 int(1) int(4) 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/DTCEC on line 58 float(1) Notice: Object of class Abc could not be converted to float in /in/DTCEC on line 59 float(1) float(4) 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/DTCEC on line 71 string(5) "Array" Notice: Array to string conversion in /in/DTCEC on line 72 string(5) "Array" Notice: Array to string conversion in /in/DTCEC on line 73 string(5) "Array" Notice: Array to string conversion in /in/DTCEC on line 74 string(5) "Array" Recoverable fatal error: Object of class stdClass could not be converted to string in /in/DTCEC on line 75
Process exited with code 255.
Output for 7.0.0 - 7.0.14
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(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/DTCEC on line 41 int(1) Notice: Object of class Abc could not be converted to int in /in/DTCEC on line 42 int(1) int(4) 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/DTCEC on line 58 float(1) Notice: Object of class Abc could not be converted to float in /in/DTCEC on line 59 float(1) float(4) 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/DTCEC on line 71 string(5) "Array" Notice: Array to string conversion in /in/DTCEC on line 72 string(5) "Array" Notice: Array to string conversion in /in/DTCEC on line 73 string(5) "Array" Notice: Array to string conversion in /in/DTCEC on line 74 string(5) "Array" Catchable fatal error: Object of class stdClass could not be converted to string in /in/DTCEC on line 75
Process exited with code 255.
Output for 5.4.0 - 5.6.28
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(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/DTCEC on line 41 int(1) Notice: Object of class Abc could not be converted to int in /in/DTCEC on line 42 int(1) int(4) 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/DTCEC on line 58 float(1) Notice: Object of class Abc could not be converted to double in /in/DTCEC on line 59 float(1) float(4) 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/DTCEC on line 71 string(5) "Array" Notice: Array to string conversion in /in/DTCEC on line 72 string(5) "Array" Notice: Array to string conversion in /in/DTCEC on line 73 string(5) "Array" Notice: Array to string conversion in /in/DTCEC on line 74 string(5) "Array" Catchable fatal error: Object of class stdClass could not be converted to string in /in/DTCEC on line 75
Process exited with code 255.