function json_encode($v) { return var2js($v); }
function parse_json($hf, $out_filename = '') { $page = var2js($hf); if ($out_filename && $out_filename != 'v' && $out_filename != 's') { $outdir = dirname($out_filename); //check dir if (!is_dir($outdir)) { mkdir($outdir, 0777); } $OUTFILE = fopen($out_filename, "w") or die("Can't open out [{$out_filename}] file"); fputs($OUTFILE, $page); fclose($OUTFILE); } else { if ($out_filename == 'v') { #variable mode return $page; } else { #screen mode print header("Content-Type: application/json"); print $page; } } }