3v4l.org

run code in 300+ PHP versions simultaneously
<?php //////////////////////////// /** * IRCBot = root directory. * * @file: IRCBot/src/Connect.php */ namespace Connect; class Connect { protected $server; // Planning to use this for the YAML config protected $port; // Planning to use this for the YAML config public function connect($server, $port) { try { fsockopen($server, $port); } catch (Exception $e) { echo "[ERROR] " . $e; } return $this; // I want to chain this function with a function called sendUserData... } } //////////////////////////// /** * IRCBot = root directory. * * @file: IRCBot/src/Start.php */ namespace Connect; class Start { // I want to run all functions on startup public function __construct(Connect $connect) { $connect->connect("irc.freenode.net", 6667); } } //////////////////////////// /** * IRCBot = root directory. * * @file: IRCBot/index.php */ //require_once 'src/Start.php'; //require_once 'src/Connect.php'; use Connect\Connect; use Connect\Start; error_reporting(E_ALL); // @TODO: [ ] Add a utility that get's the native timezone; date_default_timezone_set("UTC"); $connect = new Connect(); var_dump($connect); $start = new Start($connect); var_dump($start);
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
object(Connect\Connect)#1 (2) { ["server":protected]=> NULL ["port":protected]=> NULL } Warning: fsockopen(): php_network_getaddresses: getaddrinfo for irc.freenode.net failed: System error in /in/alkku on line 18 Warning: fsockopen(): Unable to connect to irc.freenode.net:6667 (php_network_getaddresses: getaddrinfo for irc.freenode.net failed: System error) in /in/alkku on line 18 object(Connect\Start)#2 (0) { }
Output for 8.0.13 - 8.0.30
object(Connect\Connect)#1 (2) { ["server":protected]=> NULL ["port":protected]=> NULL } Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: System error in /in/alkku on line 18 Warning: fsockopen(): Unable to connect to irc.freenode.net:6667 (php_network_getaddresses: getaddrinfo failed: System error) in /in/alkku on line 18 object(Connect\Start)#2 (0) { }
Output for 8.0.0 - 8.0.12
object(Connect\Connect)#1 (2) { ["server":protected]=> NULL ["port":protected]=> NULL } Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/alkku on line 18 Warning: fsockopen(): Unable to connect to irc.freenode.net:6667 (php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution) in /in/alkku on line 18 object(Connect\Start)#2 (0) { }
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.25, 7.3.0 - 7.3.12, 7.3.32 - 7.3.33, 7.4.0, 7.4.26 - 7.4.33
object(Connect\Connect)#1 (2) { ["server":protected]=> NULL ["port":protected]=> NULL } Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: System error in /in/alkku on line 18 Warning: fsockopen(): unable to connect to irc.freenode.net:6667 (php_network_getaddresses: getaddrinfo failed: System error) in /in/alkku on line 18 object(Connect\Start)#2 (0) { }
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.31, 7.4.3 - 7.4.25
object(Connect\Connect)#1 (2) { ["server":protected]=> NULL ["port":protected]=> NULL } Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/alkku on line 18 Warning: fsockopen(): unable to connect to irc.freenode.net:6667 (php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution) in /in/alkku on line 18 object(Connect\Start)#2 (0) { }

preferences:
253.4 ms | 402 KiB | 368 Q