php JSON 中文乱码解决方案
<?php
// 将数组转换成Json格式,中文需要进行URL编码处理
function Array2Json($array) {
arrayRecursive($array, 'urlencode', true);
$json = json_encode($array);
$json = urldecode($json);
// ext需要不带引号的bool类型
$json = str_replace("\"false\"","false",$json);
$json = str_replace("\"true\"","true",$json);
return $json;
}
function arrayRecursive(&$array, $function, $apply_to_keys_also = false)
{
static $recursive_counter = 0;
if (++$recursive_counter > 1000) {
die('possible deep recursion attack');
}
foreach ($array as $key => $value) {
if (is_array($value)) {
arrayRecursive($array[$key], $function, $apply_to_keys_also);
} else {
$array[$key] = $function($value);
}
if ($apply_to_keys_also && is_string($key)) {
$new_key = $function($key);
if ($new_key != $key) {
$array[$new_key] = $array[$key];
unset($array[$key]);
}
}
}
$recursive_counter--;
}
?>
相关文档:
伪静态用到知识很简单一旦学会,快乐无穷,只需要正则和服务器设置。
先说iis如何设置吧,往下看
下载(IIS Rewrite模块): http://www.isapirewrite.com/,先把产品下载下来,安装在服务器上,记住目录,会有类似Rewrite.dll的文件生成,MMC→IIS信息服务管理器→网站→您的站点→属性,在&ld ......
一般的文件安全下载方法可以使用下面的代码:
1. <?php?
2.
3. $durl = 'file/phpcms2008_o2abf32efj883c91a.iso';
4. $filename = 'phpcms2008_o2abf32efj883c91a.iso';
5. $file = @fopen($durl, 'r');
6. header("Content-Type: application/octet-stream");
......
今天确实是无聊了,写了一个备份人人网的日志,到本地html的类。
主要是cURL登录,正则解析页面。
使用方法,最后那个脚本的最后两行改掉,你知道的。或者重新写一个运行脚本:
<?php
include("renren.php");
$test = new renren("你的人人网账号","你的人人网密码");
$test->do ......
<?php
//作者:梁文平 http://www.tyasp.net
session_start();
if($_SESSION["username"]!="admin")
{
echo("<mce:script type="text/javascript"><!--
alert("操作超时!请重新登陆...");window.location.href="../index.php";
// --></mce:script>");
//header("refresh:0;url=../"); ......
PHP中有下列称之为魔术方法(magic method)的函数:__construct, __destruct ,
__call, __callStatic,__get, __set, __isset, __unset , __sleep, __wakeup,
__toString, __set_state, __clone and __autoload,本文使用__call为实现一个身份验证的简单实例,代码如下: 代码<?php
interfa ......