1.写文件
$fp = fopen("jsapi_ticket.json", "w+");
fwrite($fp, $str);
fclose($fp);
2.导出数据(使用header函数)
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment;filename=pc_collection_".$nodeid.'.txt');
echo base64_encode(json_encode($data));
3.解决base_decode 解密可能出现的中文乱码问题
mb_convert_encoding(base64_decode($v),"UTF-8","gb2312");
4.异或加密 解密
function xor_enc($str,$key){
$crytxt = '';
$keylen = strlen($key);
for($i=0;$i<strlen($str);$i++){
$k = $i % $keylen;
$crytxt .= $str[$i] ^ $key[$k];
}
return $crytxt;
} $str = "北京欢迎您";
$key = "Welcome";
$crytxt = xor_enc($str,$key);
echo "加密后->".$crytxt;
echo "<br>";
echo "解密后->".xor_enc($crytxt,$key);