3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $url = 'http://server.com/path'; $data = array('key1' => 'value1', 'key2' => 'value2'); // use key 'http' even if you send the request to https://... $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data), ), ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); var_dump($result);
Output for 7.0.20, 7.1.5 - 7.2.0
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/q1Xbj on line 15 Warning: file_get_contents(http://server.com/path): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/q1Xbj on line 15 bool(false)
Output for 5.2.6 - 7.0.14, 7.1.0
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/q1Xbj on line 15 Warning: file_get_contents(http://server.com/path): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/q1Xbj on line 15 bool(false)
Output for 5.2.3 - 5.2.5
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/q1Xbj on line 15 Warning: file_get_contents(http://server.com/path): failed to open stream: Connection refused in /in/q1Xbj on line 15 bool(false)
Output for 5.0.3 - 5.2.2
<br /> <b>Warning</b>: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: php_network_getaddresses: getaddrinfo failed: Name or service not known in <b>/in/q1Xbj</b> on line <b>15</b><br /> <br /> <b>Warning</b>: file_get_contents(http://server.com/path) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: Connection refused in <b>/in/q1Xbj</b> on line <b>15</b><br /> bool(false)
Output for 5.0.1 - 5.0.2
<br /> <b>Warning</b>: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: php_network_getaddresses: gethostbyname failed in <b>/in/q1Xbj</b> on line <b>15</b><br /> <br /> <b>Warning</b>: file_get_contents(http://server.com/path) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: Success in <b>/in/q1Xbj</b> on line <b>15</b><br /> bool(false)
Output for 5.0.0
<br /> <b>Warning</b>: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: php_network_getaddresses: gethostbyname failed in <b>/in/q1Xbj</b> on line <b>15</b><br /> <br /> <b>Warning</b>: file_get_contents(http://server.com/path) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: Bad file descriptor in <b>/in/q1Xbj</b> on line <b>15</b><br /> bool(false)
Output for 4.4.5 - 4.4.9
<br /> <b>Fatal error</b>: Call to undefined function: http_build_query() in <b>/in/q1Xbj</b> on line <b>11</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.4.4
<br /> <b>Fatal error</b>: Call to undefined function: http_build_query() in <b>/in/q1Xbj</b> on line <b>11</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<br /> <b>Fatal error</b>: Call to undefined function: http_build_query() in <b>/in/q1Xbj</b> on line <b>11</b><br />