Created
July 25, 2018 16:50
-
-
Save brunokunace/8f8bf21a9ea34222a79e4cb0cd2e5817 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Address { | |
public function get_address($cep) | |
{ | |
$url = "http://viacep.com.br/ws/".$cep."/xml"; | |
return simplexml_load_file($url); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require('classes/Address.php'); | |
$address = new Address(); | |
$cep = "36204-220"; | |
$newAddress = $address->get_address($cep); | |
echo "CEP Informado: ".$cep."<br />"; | |
echo "Rua:".$newAddress->logradouro."<br />"; | |
echo "Bairro:".$newAddress->bairro."<br />"; | |
echo "Estado:".$newAddress->uf."<br />"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment