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 git.master, git.master_jit, rfc.property-hooks
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.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
51.22 ms | 402 KiB | 8 Q