3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $url = 'https://www.tiny.com.br/api2/produtos.pesquisa.php'; $token = 'coloque aqui a sua chave da api'; $pesquisa = 'xxxxx'; $data = "token=$token&pesquisa=$pesquisa&formato=XML"; enviarREST($url, $data); function enviarREST($url, $data, $optional_headers = null) { $params = array('http' => array( 'method' => 'POST', 'content' => $data )); if ($optional_headers !== null) { $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); $fp = @fopen($url, 'rb', false, $ctx); if (!$fp) { throw new Exception("Problema com $url, $php_errormsg"); } $response = @stream_get_contents($fp); if ($response === false) { throw new Exception("Problema obtendo retorno de $url, $php_errormsg"); } return $response; }
Output for 7.0.0 - 7.2.0
Notice: Undefined variable: php_errormsg in /in/3q7DL on line 23 Fatal error: Uncaught Exception: Problema com https://www.tiny.com.br/api2/produtos.pesquisa.php, in /in/3q7DL:23 Stack trace: #0 /in/3q7DL(8): enviarREST('https://www.tin...', 'token=coloque a...') #1 {main} thrown in /in/3q7DL on line 23
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Notice: Undefined variable: php_errormsg in /in/3q7DL on line 23 Fatal error: Uncaught exception 'Exception' with message 'Problema com https://www.tiny.com.br/api2/produtos.pesquisa.php, ' in /in/3q7DL:23 Stack trace: #0 /in/3q7DL(8): enviarREST('https://www.tin...', 'token=coloque a...') #1 {main} thrown in /in/3q7DL on line 23
Process exited with code 255.