3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function checaClientePorto($cnpj, $codigoProduto=0) { if (strlen(trim($cnpj))>0) { $filename = "https://wwws.portoseguro.com.br/ConsultaDadoSeguradoService/REST/obterDadosSegurado?cpfcnpj=$cnpj&codigoProduto=$codigoProduto"; try { $result = simplexml_load_file($filename); $obj = json_decode(json_encode((array) $result)); $corretores = get_object_vars($obj->corretores); $retorno = null; if (is_array($corretores['susep'])) { foreach($result['susep'] as $susep) { if( !($susep instanceof stdClass) ) { $retorno = $susep; break; } } } else { $retorno = $result->corretores->susep; } if (is_null($retorno)) { $retorno=''; } //registrarLog(0, 0, 'Retorno Webservice: ' . $retorno); return $retorno; } catch (Exception $e) { return array("erro"=>$e->getMessage()); } } else { return 'ERROCPF'; } } $cpf = $_REQUEST['cpf']; echo "CPF: $cpf<br/>"; $res=checaClientePorto('34576911856'); print('<pre>Susep Retornado: '.$res.'</pre>'); echo "https://wwws.portoseguro.com.br/ConsultaDadoSeguradoService/REST/obterDadosSegurado?cpfcnpj=$cpf&codigoProduto=0";
based on DkNiA
Output for 5.4.15 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined index: cpf in /in/SJcET on line 50 CPF: <br/> Warning: simplexml_load_file(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/SJcET on line 9 Warning: simplexml_load_file(https://wwws.portoseguro.com.br/ConsultaDadoSeguradoService/REST/obterDadosSegurado?cpfcnpj=34576911856&codigoProduto=0): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/SJcET on line 9 Warning: simplexml_load_file(): I/O warning : failed to load external entity "https://wwws.portoseguro.com.br/ConsultaDadoSeguradoService/REST/obterDadosSegurado?cpfcnpj=34576911856&codigoProduto=0" in /in/SJcET on line 9 Notice: Trying to get property of non-object in /in/SJcET on line 12 Warning: get_object_vars() expects parameter 1 to be object, null given in /in/SJcET on line 12 Notice: Trying to get property of non-object in /in/SJcET on line 28 Notice: Trying to get property of non-object in /in/SJcET on line 28 <pre>Susep Retornado: </pre>https://wwws.portoseguro.com.br/ConsultaDadoSeguradoService/REST/obterDadosSegurado?cpfcnpj=&codigoProduto=0
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined index: cpf in /in/SJcET on line 50 CPF: <br/> Warning: Failed to open https://wwws.portoseguro.com.br/ConsultaDadoSeguradoService/REST/obterDadosSegurado?cpfcnpj=34576911856&codigoProduto=0 (Could not resolve host: wwws.portoseguro.com.br) in /in/SJcET on line 9 Notice: Cannot access property on non-object in /in/SJcET on line 12 Warning: get_object_vars() expects parameter 1 to be object, null given in /in/SJcET on line 12 Notice: Cannot access property on non-object in /in/SJcET on line 28 Notice: Cannot access property on non-object in /in/SJcET on line 28 <pre>Susep Retornado: </pre>https://wwws.portoseguro.com.br/ConsultaDadoSeguradoService/REST/obterDadosSegurado?cpfcnpj=&codigoProduto=0
Output for 5.3.0 - 5.4.14
Notice: Undefined index: cpf in /in/SJcET on line 50 CPF: <br/> Warning: simplexml_load_file(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/SJcET on line 9 Warning: simplexml_load_file(): I/O warning : failed to load external entity "https://wwws.portoseguro.com.br/ConsultaDadoSeguradoService/REST/obterDadosSegurado?cpfcnpj=34576911856&codigoProduto=0" in /in/SJcET on line 9 Notice: Trying to get property of non-object in /in/SJcET on line 12 Warning: get_object_vars() expects parameter 1 to be object, null given in /in/SJcET on line 12 Notice: Trying to get property of non-object in /in/SJcET on line 28 Notice: Trying to get property of non-object in /in/SJcET on line 28 <pre>Susep Retornado: </pre>https://wwws.portoseguro.com.br/ConsultaDadoSeguradoService/REST/obterDadosSegurado?cpfcnpj=&codigoProduto=0
Output for 5.2.0 - 5.2.17
Notice: Undefined index: cpf in /in/SJcET on line 50 CPF: <br/> Notice: simplexml_load_file(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/SJcET on line 9 Warning: simplexml_load_file(): I/O warning : failed to load external entity "https://wwws.portoseguro.com.br/ConsultaDadoSeguradoService/REST/obterDadosSegurado?cpfcnpj=34576911856&codigoProduto=0" in /in/SJcET on line 9 Notice: Trying to get property of non-object in /in/SJcET on line 12 Notice: Trying to get property of non-object in /in/SJcET on line 28 Notice: Trying to get property of non-object in /in/SJcET on line 28 <pre>Susep Retornado: </pre>https://wwws.portoseguro.com.br/ConsultaDadoSeguradoService/REST/obterDadosSegurado?cpfcnpj=&codigoProduto=0
Output for 5.1.0 - 5.1.6
Notice: Undefined index: cpf in /in/SJcET on line 50 CPF: <br/> Notice: simplexml_load_file(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/SJcET on line 9 Warning: simplexml_load_file(): I/O warning : failed to load external entity "https://wwws.portoseguro.com.br/ConsultaDadoSeguradoService/REST/obterDadosSegurado?cpfcnpj=34576911856&codigoProduto=0" in /in/SJcET on line 9 Fatal error: Call to undefined function json_decode() in /in/SJcET on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Notice: Undefined index: cpf in /in/SJcET on line 50 CPF: <br/> Notice: simplexml_load_file(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/SJcET on line 9 Notice: simplexml_load_file(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/SJcET on line 9 Warning: I/O warning : failed to load external entity "https://wwws.portoseguro.com.br/ConsultaDadoSeguradoService/REST/obterDadosSegurado?cpfcnpj=34576911856&codigoProduto=0" in /in/SJcET on line 9 Fatal error: Call to undefined function json_decode() in /in/SJcET on line 11
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '{' in /in/SJcET on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '{' in /in/SJcET on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/SJcET on line 8
Process exited with code 255.