Created
October 30, 2013 12:21
-
-
Save Bolinha1/7231742 to your computer and use it in GitHub Desktop.
Json
This file contains hidden or 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 | |
| $json = file_get_contents('http://localhost/json/json.php'); // só alterei o caminho | |
| $obj = json_decode($json); | |
| var_dump($obj); | |
| print_r($obj); | |
| /* | |
| var_dump | |
| object(stdClass)#1 (4) { | |
| ["locutor"]=> | |
| string(4) "Joke" | |
| ["programa"]=> | |
| string(5) "J-MIX" | |
| ["musica"]=> | |
| string(26) "Asian Kung Fu - Generation" | |
| ["ouvintes"]=> | |
| string(1) "4" | |
| } | |
| print_r | |
| stdClass Object | |
| ( | |
| [locutor] => Joke | |
| [programa] => J-MIX | |
| [musica] => Asian Kung Fu - Generation | |
| [ouvintes] => 4 | |
| ) | |
| */ |
This file contains hidden or 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 | |
| header('Content-Type: application/json'); | |
| $json = array( | |
| 'locutor'=>'Joke', | |
| 'programa'=>'J-MIX', | |
| 'musica'=>'Asian Kung Fu - Generation', | |
| 'ouvintes'=>'4' | |
| ); | |
| print json_encode($json); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment