-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathexample-1.php
More file actions
35 lines (26 loc) · 788 Bytes
/
example-1.php
File metadata and controls
35 lines (26 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
// WARNING
//
// this example needs the .htaccess included in this repo
// as per http://stackoverflow.com/questions/6987929/preparing-php-application-to-use-with-utf-8
// or the Japanese Unicode characters in the example JSON file
// won't make it through the ordeal alive!
require_once("nicejson.php");
header('content-type: text/html; charset: utf-8');
echo <<<EOT
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<h1>JSON dump</h1>
<pre>
EOT;
// Example usage
$file = dirname(__FILE__) . '/example.json';
$json = file_get_contents($file);
// strip off optional Unicode BOM:
if (substr($json, 0, 3) == "\xEF\xBB\xBF") {
$json = substr($json, 3);
}
echo htmlspecialchars(json_format($json));