3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MyClass{} $testobj = new MyClass; $teststring = ''; $testinteger = 0; $testfloat = 0.0; $testarray = array(); $testresource = fopen("http://ya.ru", "r"); $testboolean = false; if(empty($testobj)) echo "TestObj is empty - ". gettype($testobj); else var_dump($testobj); if(empty($testnull)) echo 'TestNUll is empty - '. gettype($testnull); // if(empty($teststring)) echo 'TestString is empty - '.gettype($teststring); // if(empty($testinteger)) echo 'TestInteger is empty - '.gettype($testinteger); if(empty($testfloat)) echo 'TestFloat is empty - '.gettype($testfloat); if(empty($testarray)) echo 'TestArray is empty'.gettype($testarray); if(empty($testresource)) echo 'TestResource is empty'.gettype($testresource); else echo "TestResource is not empty"; var_dump($testresource); if(empty($testboolean)) echo 'TestFloat is empty - '.gettype($testboolean); ?>
based on pOeUr
Output for 7.0.20, 7.1.5 - 7.3.0beta1
Warning: fopen(): php_network_getaddresses: getaddrinfo failed: System error in /in/JOs3A on line 8 Warning: fopen(http://ya.ru): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/JOs3A on line 8 object(MyClass)#1 (0) { } Notice: Undefined variable: testnull in /in/JOs3A on line 17 TestNUll is empty - NULLTestString is empty - stringTestInteger is empty - integerTestFloat is empty - doubleTestArray is emptyarrayTestResource is emptybooleanbool(false) TestFloat is empty - boolean
Output for 5.5.0 - 7.0.7, 7.1.0
Warning: fopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/JOs3A on line 8 Warning: fopen(http://ya.ru): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/JOs3A on line 8 object(MyClass)#1 (0) { } Notice: Undefined variable: testnull in /in/JOs3A on line 17 TestNUll is empty - NULLTestString is empty - stringTestInteger is empty - integerTestFloat is empty - doubleTestArray is emptyarrayTestResource is emptybooleanbool(false) TestFloat is empty - boolean