3v4l.org

run code in 300+ PHP versions simultaneously
<?php class String { var $string = ''; function String($string = ''){ $this->string = strval($string); } function __toString(){ return $this->string; } } var_dump((int)"123"); var_dump((float)"123"); var_dump((array)"123"); var_dump((string)"123"); var_dump((bool)"123"); var_dump((object)"123"); var_dump((int)new String("123")); var_dump((float)new String("123")); var_dump((array)new String("123")); var_dump((string)new String("123")); var_dump((bool)new String("123")); var_dump((object)new String("123"));
Output for 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.8 - 5.6.28
int(123) float(123) array(1) { [0]=> string(3) "123" } string(3) "123" bool(true) object(stdClass)#1 (1) { ["scalar"]=> string(3) "123" } Notice: Object of class String could not be converted to int in /in/qTCTj on line 21 int(1) Notice: Object of class String could not be converted to double in /in/qTCTj on line 22 float(1) array(1) { ["string"]=> string(3) "123" } string(3) "123" bool(true) object(String)#1 (1) { ["string"]=> string(3) "123" }
Output for 5.1.3 - 5.1.6
int(123) float(123) array(1) { [0]=> string(3) "123" } string(3) "123" bool(true) object(stdClass)#1 (1) { ["scalar"]=> string(3) "123" } Notice: Object of class String could not be converted to int in /in/qTCTj on line 21 int(1) Notice: Object of class String could not be converted to double in /in/qTCTj on line 22 float(1) array(1) { ["string"]=> string(3) "123" } string(12) "Object id #1" bool(true) object(String)#1 (1) { ["string"]=> string(3) "123" }
Output for 5.1.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/qTCTj on line 3 int(123) float(123) array(1) { [0]=> string(3) "123" } string(3) "123" bool(true) object(stdClass)#1 (1) { ["scalar"]=> string(3) "123" } Notice: Object of class String could not be converted to int in /in/qTCTj on line 21 int(1) Notice: Object of class String could not be converted to double in /in/qTCTj on line 22 float(1) array(1) { ["string"]=> string(3) "123" } string(12) "Object id #1" bool(true) object(String)#1 (1) { ["string"]=> string(3) "123" }
Output for 5.0.0 - 5.0.5
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/qTCTj on line 3 int(123) float(123) array(1) { [0]=> string(3) "123" } string(3) "123" bool(true) object(stdClass)#1 (1) { ["scalar"]=> string(3) "123" } object(String)#1 (1) { ["string"]=> string(3) "123" } Notice: Object of class String could not be converted to double in /in/qTCTj on line 22 float(1) array(1) { ["string"]=> string(3) "123" } string(12) "Object id #1" bool(true) object(String)#1 (1) { ["string"]=> string(3) "123" }
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9
int(123) float(123) array(1) { [0]=> string(3) "123" } string(3) "123" bool(true) object(stdClass)(1) { ["scalar"]=> string(3) "123" } int(1) float(1) array(1) { ["string"]=> string(3) "123" } Notice: Object to string conversion in /in/qTCTj on line 24 string(6) "Object" bool(true) object(string)(1) { ["string"]=> string(3) "123" }

preferences:
243.87 ms | 1387 KiB | 162 Q