3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php if (strnatcmp(phpversion(),'5.4.7') >= 0) { $address="127.0.0.1"; $port=9878; echo "I am here"; set_time_limit (0); echo "1"; if(false==($socket= socket_create(AF_INET,SOCK_STREAM, SOL_TCP))) { echo "2"; echo "could not create socket"; } echo "3"; socket_bind($socket, $address, $port) or die ("could not bind socket"); echo "4"; socket_listen($socket); echo "5"; if(($client=socket_accept($socket))) echo "6"; echo "client is here"; sleep(60); socket_close($socket); } ?>
Output for 7.0.0 - 7.1.0
I am here1 Fatal error: Uncaught Error: Call to undefined function socket_create() in /in/UZvvM:9 Stack trace: #0 {main} thrown in /in/UZvvM on line 9
Process exited with code 255.
Output for hhvm-3.12.0
I am here13 Warning: unable to bind address127.0.0.1:9878 [98]: Address already in use in /in/UZvvM on line 15 could not bind socket
Output for hhvm-3.10.0
I am here1345
Process exited with code 137.
Output for 5.4.7 - 5.6.28
I am here1 Fatal error: Call to undefined function socket_create() in /in/UZvvM on line 9
Process exited with code 255.
Output for 4.3.0 - 5.4.6