Advertisement
ph4x35ccb

Requisição CEP

Apr 8th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.31 KB | None | 0 0
  1. <?php
  2. //use diretorio/?cep=12345678
  3. $cep = $_GET['cep'];
  4. $xml = file_get_contents("http://api.postmon.com.br/v1/cep/$cep?format=xml");
  5.  
  6. $end = new SimpleXMLElement($xml);
  7.  
  8. echo 'Logradouro: '.$end->logradouro;
  9. echo '<br>Bairro: '.$end->bairro;
  10. echo '<br>Cidade: '.$end->cidade;
  11. echo '<br>Estado: '.$end->estado;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement