Example #1
0
        // self::writeXmlToFile ( 'newxml.xml', $xml );
        return $data;
    }
    public function writeStringToFile($filename)
    {
        $data = self::assembleArray();
        $str = json_encode($data);
        $fp = fopen($filename, 'w');
        // 打开要写入 XML数据的文件
        fwrite($fp, $str);
        // 写入 XML数据
        fclose($fp);
        // 关闭文件
    }
    public function writeCommPicToFile($filename)
    {
        $data = self::getCommPic($this->query7);
        $str = json_encode($data);
        $fp = fopen($filename, 'w');
        // 打开要写入 XML数据的文件
        fwrite($fp, $str);
        // 写入 XML数据
        fclose($fp);
        // 关闭文件
    }
}
// header ( "Content-Type: text/html; charset=utf-8" );
header('Content-type: application/json; charset=utf-8');
$sougou = new Sogou();
$arr = $sougou->writeStringToFile('staticschool.json');
//$arr = $sougou->writeCommPicToFile ( 'commpic.json' );