3v4l.org

run code in 300+ PHP versions simultaneously
<?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";
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined array key "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 Warning: Attempt to read property "corretores" on array in /in/SJcET on line 12 Fatal error: Uncaught TypeError: get_object_vars(): Argument #1 ($object) must be of type object, null given in /in/SJcET:12 Stack trace: #0 /in/SJcET(12): get_object_vars(NULL) #1 /in/SJcET(52): checaClientePorto('34576911856') #2 {main} thrown in /in/SJcET on line 12
Process exited with code 255.
Output for 7.4.0 - 7.4.33
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 'corretores' 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 access array offset on value of type null in /in/SJcET on line 16 Notice: Trying to get property 'corretores' of non-object in /in/SJcET on line 28 Notice: Trying to get property 'susep' 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 7.3.32 - 7.3.33
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 Warning: get_object_vars() expects parameter 1 to be object, null given in /in/SJcET on line 12 <pre>Susep Retornado: </pre>https://wwws.portoseguro.com.br/ConsultaDadoSeguradoService/REST/obterDadosSegurado?cpfcnpj=&codigoProduto=0
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31
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 'corretores' 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 'corretores' of non-object in /in/SJcET on line 28 Notice: Trying to get property 'susep' 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.3.0 - 5.3.29, 5.4.0 - 5.4.14, 7.1.20 - 7.1.33
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 7.0.20, 7.1.5 - 7.1.10
Notice: Undefined index: cpf in /in/SJcET on line 50 CPF: <br/> Warning: simplexml_load_file(): php_network_getaddresses: getaddrinfo failed: System error 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: System error 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.4.15 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.14, 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 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.3.11, 4.4.0 - 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.

preferences:
278.24 ms | 401 KiB | 395 Q