3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $host = "100.42.56.12"; $port = 7777; $message = "Hello Server"; echo "Message To server :".$message; // create socket $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); // connect to server $result = socket_connect($socket, $host, $port) or die("Could not connect to server\n"); // send string to server socket_write($socket, $message, strlen($message)) or die("Could not send data to server\n"); // get server response $result = socket_read ($socket, 1024) or die("Could not read server response\n"); echo "Reply From Server :".$result; // close socket socket_close($socket);
Output for 7.0.0 - 7.2.0
Message To server :Hello Server Fatal error: Uncaught Error: Call to undefined function socket_create() in /in/p9RU3:8 Stack trace: #0 {main} thrown in /in/p9RU3 on line 8
Process exited with code 255.
Output for 5.4.0 - 5.6.21
Message To server :Hello Server Fatal error: Call to undefined function socket_create() in /in/p9RU3 on line 8
Process exited with code 255.
Output for 5.0.0 - 5.3.29
Message To server :Hello Server Warning: socket_connect(): unable to connect [101]: Network is unreachable in /in/p9RU3 on line 10 Could not connect to server
Output for 4.3.2 - 4.4.9
Message To server :Hello Server Warning: socket_connect() unable to connect [101]: Network is unreachable in /in/p9RU3 on line 10 Could not connect to server
Output for 4.3.0 - 4.3.1
Message To server :Hello Server
Process exited with code 139.