PHP如何获取MySQL数据库中的所有表?

回复

zkbhj 回复了问题 • 1 人关注 • 1 个回复 • 4182 次浏览 • 2017-05-22 12:04 • 来自相关话题

如何把日期转换成前n天?

回复

zkbhj 回复了问题 • 1 人关注 • 1 个回复 • 2644 次浏览 • 2017-05-22 12:01 • 来自相关话题

常用的PHP时间格式转换

zkbhj 发表了文章 • 0 个评论 • 1389 次浏览 • 2017-05-22 11:52 • 来自相关话题

date

用法: date(格式,[时间]);

如果没有时间参数,则使用当前时间. 格式是一个字符串,其中以下字符有特殊意义:

U 替换成从一个起始时间1970年1月1日以来的秒数
<?php
echo "时间格式1:".date("Y-m-d H:i:s ")."<br>";// 2010-06-12 10:26:31
echo "时间格式2:".date("y-M-D h:i:S ")."<br>";// 10-Jun-Sat 10:43:th
echo "月份,英文全名:".date("F")."<br>";// June
echo "月份,二位数字,补零:".date("m")."<br>";// 06
echo "月份,二位数字,不补零:".date("n")."<br>";// 6
echo "月份,三个英文:".date("M")."<br>";// Jun
echo "星期几,英文全名:".date("l")."<br>";// Saturday
echo "星期几,三个英文:".date("D")."<br>";// Sat
echo "星期几,数字型:".date("w")."<br>";// 6
?>
Y - 年,四位数字; 如: "1999"y - 年,二位数字; 如: "99"z - 一年中的第几天; 如: "0" 至 "365"F - 月份,英文全名; 如: "January"m - 月份,二位数字,若不足二位则在前面补零; 如: "01" 至 "12"n - 月份,二位数字,若不足二位则不补零; 如: "1" 至 "12"M - 月份,三个英文字母; 如: "Jan"t - 指定月份的天数; 如: "28" 至 "31"d - 几日,二位数字,若不足二位则前面补零; 如: "01" 至 "31"j - 几日,二位数字,若不足二位不补零; 如: "1" 至 "31"h - 12 小时制的小时; 如: "01" 至 "12"H - 24 小时制的小时; 如: "00" 至 "23"g - 12 小时制的小时,不足二位不补零; 如: "1" 至 12"G - 24 小时制的小时,不足二位不补零; 如: "0" 至 "23"i - 分钟; 如: "00" 至 "59"s - 秒; 如: "00" 至 "59"S - 字尾加英文序数,二个英文字母; 如: "th","nd"U - 总秒数D - 星期几,三个英文字母; 如: "Fri"l - 星期几,英文全名; 如: "Friday"w - 数字型的星期几,如: "0" (星期日) 至 "6" (星期六)a - "am" 或是 "pm"A - "AM" 或是 "PM" 查看全部
date

用法: date(格式,[时间]);

如果没有时间参数,则使用当前时间. 格式是一个字符串,其中以下字符有特殊意义:

U 替换成从一个起始时间1970年1月1日以来的秒数
<?php  
echo "时间格式1:".date("Y-m-d H:i:s ")."<br>";// 2010-06-12 10:26:31
echo "时间格式2:".date("y-M-D h:i:S ")."<br>";// 10-Jun-Sat 10:43:th
echo "月份,英文全名:".date("F")."<br>";// June
echo "月份,二位数字,补零:".date("m")."<br>";// 06
echo "月份,二位数字,不补零:".date("n")."<br>";// 6
echo "月份,三个英文:".date("M")."<br>";// Jun
echo "星期几,英文全名:".date("l")."<br>";// Saturday
echo "星期几,三个英文:".date("D")."<br>";// Sat
echo "星期几,数字型:".date("w")."<br>";// 6
?>

  • Y - 年,四位数字; 如: "1999"
  • y - 年,二位数字; 如: "99"
  • z - 一年中的第几天; 如: "0" 至 "365"
  • F - 月份,英文全名; 如: "January"
  • m - 月份,二位数字,若不足二位则在前面补零; 如: "01" 至 "12"
  • n - 月份,二位数字,若不足二位则不补零; 如: "1" 至 "12"
  • M - 月份,三个英文字母; 如: "Jan"
  • t - 指定月份的天数; 如: "28" 至 "31"
  • d - 几日,二位数字,若不足二位则前面补零; 如: "01" 至 "31"
  • j - 几日,二位数字,若不足二位不补零; 如: "1" 至 "31"
  • h - 12 小时制的小时; 如: "01" 至 "12"
  • H - 24 小时制的小时; 如: "00" 至 "23"
  • g - 12 小时制的小时,不足二位不补零; 如: "1" 至 12"
  • G - 24 小时制的小时,不足二位不补零; 如: "0" 至 "23"
  • i - 分钟; 如: "00" 至 "59"
  • s - 秒; 如: "00" 至 "59"
  • S - 字尾加英文序数,二个英文字母; 如: "th","nd"
  • U - 总秒数
  • D - 星期几,三个英文字母; 如: "Fri"
  • l - 星期几,英文全名; 如: "Friday"
  • w - 数字型的星期几,如: "0" (星期日) 至 "6" (星期六)
  • a - "am" 或是 "pm"
  • A - "AM" 或是 "PM"

PHP使用FTP实现文件上传代码类

zkbhj 发表了文章 • 0 个评论 • 1326 次浏览 • 2017-05-05 14:12 • 来自相关话题

<?php
/**
* ftp上传文件类
*/
class Ftp {

/**
* 测试服务器
*
* @var array
*/
private $testServer = array(
'host' => 'ip',
'port' => 21,
'user' => 'userName',
'pwd' => 'password'
);

/**
* 打开并登录服务器
*
* @param string $flag 服务器标识test
* @return mixed
* 0:服务器连接失败
* 1:服务器登录失败
* resource 连接标识
*/
public function openServer($flag = 'test'){
//选择服务器
$config = $this->getServerConfig($flag);

//连接服务器
$connect = ftp_connect($config['host'], $config['port']);
if($connect == false) return 0;

//登录服务器
if(!ftp_login($connect, $config['user'], $config['pwd'])) return 1;

//打开被动模式,数据的传送由客户机启动,而不是由服务器开始
ftp_pasv($connect, true);

//返回连接标识
return $connect;
}

/**
* 创建目录并将目录定位到当请目录
*
* @param resource $connect 连接标识
* @param string $dirPath 目录路径
* @return mixed
* 2:创建目录失败
* true:创建目录成功
*/
public function makeDir($connect, $dirPath){
//处理目录
$dirPath = '/' . trim($dirPath, '/');
$dirPath = explode('/', $dirPath);
foreach ($dirPath as $dir){
if($dir == '') $dir = '/';
//判断目录是否存在
if(@ftp_chdir($connect, $dir) == false){
//判断目录是否创建成功
if(@ftp_mkDir($connect, $dir) == false){
return 2;
}
@ftp_chdir($connect, $dir);
}
}
return true;
}

/**
* 关闭服务器
*
* @param resource $connect 连接标识
*/
public function closeServer($connect){
if(!empty($connect)) ftp_close($connect);
}

/**
* 上传文件
*
* @param string $flag 服务器标识
* @param string $local 上传文件的本地路径
* @param string $remote 上传文件的远程路径
* @return int
* 0:服务器连接失败
* 1:服务器登录失败
* 2:创建目录失败
* 3:上传文件失败
* 4:上传成功
*/
public function upload($flag = 'test', $local, $remote){
//连接并登录服务器
$connect = $this->openServer($flag);
if(($connect === 0) || ($connect === 1)) return $connect;

//上传文件目录处理
$mdr = $this->makeDir($connect, dirname($remote));
if($mdr === 2) return 2;

//上传文件
$result = ftp_put($connect, basename($remote), $local, FTP_BINARY);

//关闭服务器
$this->closeServer($connect);

//返回结果
return (!$result) ? 3 : 4;
}

/**
* 删除文件
*
* @param string $flag 服务器标识
* @param string $remote 文件的远程路径
* @return int
* 0:服务器连接失败
* 1:服务器登录失败
* 2:删除失败
* 3:删除成功
*/
public function delete($flag = 'test', $remote){
//连接并登录服务器
$connect = $this->openServer($flag);
if(($connect === 0) || ($connect === 1)) return $connect;

//删除
$result = ftp_delete($connect, $remote);

//关闭服务器
$this->closeServer($connect);

//返回结果
return (!$result) ? 2 : 3;
}

/**
* 读取文件
*
* @param string $flag 服务器标识
* @param string $remote 文件的远程路径
* @return mixed
* 0:服务器连接失败
* 1:服务器登录失败
*/
public function read($flag, $remote){
//连接并登录服务器
$connect = $this->openServer($flag);
if(($connect === 0) || ($connect === 1)) return $connect;

//读取
$result = ftp_nlist($connect, $remote);

//关闭服务器
$this->closeServer($connect);

//返回结果
foreach ($result as $key => $value){
if(in_array($value, array('.', '..'))) unset($result[$key]);
}
return array_values($result);
}

/**
* 获取ftp服务器配置
*
* @param string $flag 服务器标识test
* @return array ftp服务器连接配置
*/
private function getServerConfig($flag = 'test'){
$flag = strtolower($flag);
//测试服务器
if($flag == 'test') return $this->testServer;
//默认返回测试服务器
return $this->testServer;
}
}
?> 查看全部

<?php
/**
* ftp上传文件类
*/
class Ftp {

/**
* 测试服务器
*
* @var array
*/
private $testServer = array(
'host' => 'ip',
'port' => 21,
'user' => 'userName',
'pwd' => 'password'
);

/**
* 打开并登录服务器
*
* @param string $flag 服务器标识test
* @return mixed
* 0:服务器连接失败
* 1:服务器登录失败
* resource 连接标识
*/
public function openServer($flag = 'test'){
//选择服务器
$config = $this->getServerConfig($flag);

//连接服务器
$connect = ftp_connect($config['host'], $config['port']);
if($connect == false) return 0;

//登录服务器
if(!ftp_login($connect, $config['user'], $config['pwd'])) return 1;

//打开被动模式,数据的传送由客户机启动,而不是由服务器开始
ftp_pasv($connect, true);

//返回连接标识
return $connect;
}

/**
* 创建目录并将目录定位到当请目录
*
* @param resource $connect 连接标识
* @param string $dirPath 目录路径
* @return mixed
* 2:创建目录失败
* true:创建目录成功
*/
public function makeDir($connect, $dirPath){
//处理目录
$dirPath = '/' . trim($dirPath, '/');
$dirPath = explode('/', $dirPath);
foreach ($dirPath as $dir){
if($dir == '') $dir = '/';
//判断目录是否存在
if(@ftp_chdir($connect, $dir) == false){
//判断目录是否创建成功
if(@ftp_mkDir($connect, $dir) == false){
return 2;
}
@ftp_chdir($connect, $dir);
}
}
return true;
}

/**
* 关闭服务器
*
* @param resource $connect 连接标识
*/
public function closeServer($connect){
if(!empty($connect)) ftp_close($connect);
}

/**
* 上传文件
*
* @param string $flag 服务器标识
* @param string $local 上传文件的本地路径
* @param string $remote 上传文件的远程路径
* @return int
* 0:服务器连接失败
* 1:服务器登录失败
* 2:创建目录失败
* 3:上传文件失败
* 4:上传成功
*/
public function upload($flag = 'test', $local, $remote){
//连接并登录服务器
$connect = $this->openServer($flag);
if(($connect === 0) || ($connect === 1)) return $connect;

//上传文件目录处理
$mdr = $this->makeDir($connect, dirname($remote));
if($mdr === 2) return 2;

//上传文件
$result = ftp_put($connect, basename($remote), $local, FTP_BINARY);

//关闭服务器
$this->closeServer($connect);

//返回结果
return (!$result) ? 3 : 4;
}

/**
* 删除文件
*
* @param string $flag 服务器标识
* @param string $remote 文件的远程路径
* @return int
* 0:服务器连接失败
* 1:服务器登录失败
* 2:删除失败
* 3:删除成功
*/
public function delete($flag = 'test', $remote){
//连接并登录服务器
$connect = $this->openServer($flag);
if(($connect === 0) || ($connect === 1)) return $connect;

//删除
$result = ftp_delete($connect, $remote);

//关闭服务器
$this->closeServer($connect);

//返回结果
return (!$result) ? 2 : 3;
}

/**
* 读取文件
*
* @param string $flag 服务器标识
* @param string $remote 文件的远程路径
* @return mixed
* 0:服务器连接失败
* 1:服务器登录失败
*/
public function read($flag, $remote){
//连接并登录服务器
$connect = $this->openServer($flag);
if(($connect === 0) || ($connect === 1)) return $connect;

//读取
$result = ftp_nlist($connect, $remote);

//关闭服务器
$this->closeServer($connect);

//返回结果
foreach ($result as $key => $value){
if(in_array($value, array('.', '..'))) unset($result[$key]);
}
return array_values($result);
}

/**
* 获取ftp服务器配置
*
* @param string $flag 服务器标识test
* @return array ftp服务器连接配置
*/
private function getServerConfig($flag = 'test'){
$flag = strtolower($flag);
//测试服务器
if($flag == 'test') return $this->testServer;
//默认返回测试服务器
return $this->testServer;
}
}
?>

如何校验身份证格式?

回复

zkbhj 回复了问题 • 1 人关注 • 1 个回复 • 2665 次浏览 • 2017-05-12 18:12 • 来自相关话题

在PHP中的header函数

zkbhj 发表了文章 • 0 个评论 • 1162 次浏览 • 2017-04-14 17:19 • 来自相关话题

header('HTTP/1.1 200 OK');  // ok 正常访问
header('HTTP/1.1 404 Not Found'); //通知浏览器 页面不存在
header('HTTP/1.1 301 Moved Permanently'); //设置地址被永久的重定向 301
header('Location: http://www.ithhc.cn/'); //跳转到一个新的地址
header('Refresh: 10; url=http://www.ithhc.cn/'); //延迟转向 也就是隔几秒跳转
header('X-Powered-By: PHP/6.0.0'); //修改 X-Powered-By信息
header('Content-language: en'); //文档语言
header('Content-Length: 1234'); //设置内容长度
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT'); //告诉浏览器最后一次修改时间
header('HTTP/1.1 304 Not Modified'); //告诉浏览器文档内容没有发生改变
  
###内容类型###
header('Content-Type: text/html; charset=utf-8'); //网页编码
header('Content-Type: text/plain'); //纯文本格式
header('Content-Type: image/jpeg'); //JPG、JPEG
header('Content-Type: application/zip'); // ZIP文件
header('Content-Type: application/pdf'); // PDF文件
header('Content-Type: audio/mpeg'); // 音频文件
header('Content-type: text/css'); //css文件
header('Content-type: text/javascript'); //js文件
header('Content-type: application/json');  //json
header('Content-type: application/pdf'); //pdf
header('Content-type: text/xml');  //xml
header('Content-Type: application/x-shockw**e-flash'); //Flash动画
  
######
  
###声明一个下载的文件###
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="ITblog.zip"');
header('Content-Transfer-Encoding: binary');
readfile('test.zip');
######
  
###对当前文档禁用缓存###
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
######
  
###显示一个需要验证的登陆对话框###
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Top Secret"');
######
  
  
###声明一个需要下载的xls文件###
header('Content-Disposition: attachment; filename=ithhc.xlsx');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Length: '.filesize('./test.xls'));
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate');
header('Pragma: public');
readfile('./test.xls');
###### 查看全部

header('HTTP/1.1 200 OK');  // ok 正常访问
header('HTTP/1.1 404 Not Found'); //通知浏览器 页面不存在
header('HTTP/1.1 301 Moved Permanently'); //设置地址被永久的重定向 301
header('Location: http://www.ithhc.cn/'); //跳转到一个新的地址
header('Refresh: 10; url=http://www.ithhc.cn/'); //延迟转向 也就是隔几秒跳转
header('X-Powered-By: PHP/6.0.0'); //修改 X-Powered-By信息
header('Content-language: en'); //文档语言
header('Content-Length: 1234'); //设置内容长度
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT'); //告诉浏览器最后一次修改时间
header('HTTP/1.1 304 Not Modified'); //告诉浏览器文档内容没有发生改变
  
###内容类型###
header('Content-Type: text/html; charset=utf-8'); //网页编码
header('Content-Type: text/plain'); //纯文本格式
header('Content-Type: image/jpeg'); //JPG、JPEG
header('Content-Type: application/zip'); // ZIP文件
header('Content-Type: application/pdf'); // PDF文件
header('Content-Type: audio/mpeg'); // 音频文件
header('Content-type: text/css'); //css文件
header('Content-type: text/javascript'); //js文件
header('Content-type: application/json');  //json
header('Content-type: application/pdf'); //pdf
header('Content-type: text/xml');  //xml
header('Content-Type: application/x-shockw**e-flash'); //Flash动画
  
######
  
###声明一个下载的文件###
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="ITblog.zip"');
header('Content-Transfer-Encoding: binary');
readfile('test.zip');
######
  
###对当前文档禁用缓存###
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
######
  
###显示一个需要验证的登陆对话框###
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Top Secret"');
######
  
  
###声明一个需要下载的xls文件###
header('Content-Disposition: attachment; filename=ithhc.xlsx');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Length: '.filesize('./test.xls'));
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate');
header('Pragma: public');
readfile('./test.xls');
######

PHP函数:array_reverse

zkbhj 发表了文章 • 0 个评论 • 1201 次浏览 • 2017-03-17 14:29 • 来自相关话题

array_reverse函数可返回一个单元顺序相反的数组,如果可选参数为true,则保留原来的键名。

语法  array array_reverse ( array input [, bool preserve_keys]) 

input为必选参数,输入的数组;preserve_keys为可选参数。如果指定了该参数,保留原来的键名,该参数的值为true或false,这个参数是 php 4.0.3 中新加的。

示例  本示例应用array_reverse()函数将数组的单元顺序反转。代码如下:<?php
$arr = array ("asp", "php", "jsp");
$result = array_reverse($arr);
print_r($result);
$result2 = array_reverse($arr, true);
print_r($result2);
?>
本示例的运行结果如下:Array( [0]=> jsp [1]=> php [2]=> asp)
Array( [2]=> jsp[1]=> php [0]=> asp) 查看全部
array_reverse函数可返回一个单元顺序相反的数组,如果可选参数为true,则保留原来的键名。

语法  array array_reverse ( array input [, bool preserve_keys]) 

input为必选参数,输入的数组;preserve_keys为可选参数。如果指定了该参数,保留原来的键名,该参数的值为true或false,这个参数是 php 4.0.3 中新加的。

示例  本示例应用array_reverse()函数将数组的单元顺序反转。代码如下:
<?php
$arr = array ("asp", "php", "jsp");
$result = array_reverse($arr);
print_r($result);
$result2 = array_reverse($arr, true);
print_r($result2);
?>

本示例的运行结果如下:
Array( [0]=> jsp [1]=> php [2]=> asp)
Array( [2]=> jsp[1]=> php [0]=> asp)

yum方式安装PHP比较齐全的安装方式

zkbhj 发表了文章 • 0 个评论 • 1159 次浏览 • 2017-03-02 14:15 • 来自相关话题

yum install php70w.x86_64 php70w-bcmath.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-dba.x86_64 php70w-devel.x86_64 php70w-embedded.x86_64 php70w-enchant.x86_64 php70w-fpm.x86_64 php70w-gd.x86_64 php70w-imap.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysqlnd.x86_64 php70w-odbc.x86_64 php70w-opcache.x86_64 php70w-pdo.x86_64 php70w-pdo_dblib.x86_64 php70w-pear.noarch php70w-pecl-apcu.x86_64 php70w-pecl-apcu-devel.x86_64 php70w-pecl-imagick.x86_64 php70w-pecl-imagick-devel.x86_64 php70w-pecl-mongodb.x86_64 php70w-pecl-redis.x86_64 php70w-pecl-xdebug.x86_64 php70w-pgsql.x86_64 php70w-xml.x86_64 php70w-xmlrpc.x86_64 nginx php70w-intl -y

php70w-mysqlnd.x86_64 查看全部
yum install php70w.x86_64 php70w-bcmath.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-dba.x86_64 php70w-devel.x86_64 php70w-embedded.x86_64 php70w-enchant.x86_64 php70w-fpm.x86_64 php70w-gd.x86_64 php70w-imap.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysqlnd.x86_64 php70w-odbc.x86_64 php70w-opcache.x86_64 php70w-pdo.x86_64 php70w-pdo_dblib.x86_64 php70w-pear.noarch php70w-pecl-apcu.x86_64 php70w-pecl-apcu-devel.x86_64 php70w-pecl-imagick.x86_64 php70w-pecl-imagick-devel.x86_64 php70w-pecl-mongodb.x86_64 php70w-pecl-redis.x86_64 php70w-pecl-xdebug.x86_64 php70w-pgsql.x86_64 php70w-xml.x86_64 php70w-xmlrpc.x86_64 nginx php70w-intl -y

php70w-mysqlnd.x86_64

PHP如何实现几天前、几小时前、几秒前的功能?

回复

zkbhj 回复了问题 • 1 人关注 • 1 个回复 • 4398 次浏览 • 2017-03-01 17:37 • 来自相关话题

PHP中把stdClass Object转array的几个方法

zkbhj 发表了文章 • 0 个评论 • 1347 次浏览 • 2017-03-01 14:36 • 来自相关话题

PHP和JS通讯通常都用json,但用 json 传过来的数组并不是标准的array,而是 stdClass 类型。那么我们可以参考下面的几个方法进行转换。
 
方法一:
//PHP stdClass Object转array
function object_array($array) {
if(is_object($array)) {
$array = (array)$array;
} if(is_array($array)) {
foreach($array as $key=>$value) {
$array[$key] = object_array($value);
}
}
return $array;
}方法二:
$array = json_decode(json_encode(simplexml_load_string($xmlString)),TRUE);方法三:
function object2array_pre(&$object) {
if (is_object($object)) {
$arr = (array)($object);
} else {
$arr = &$object;
}
if (is_array($arr)) {
foreach($arr as $varName => $varValue){
$arr[$varName] = $this->object2array($varValue);
}
}
return $arr;
}```


如果是10W的数据量的话,执行要进1s,结构再复杂些,可以达到3s, 性能太差了
可以用以下替换:

function object2array(&$object) {

$object = json_decode( json_encode( $object),true);
return $object;
}


但是对json的特性,只能是针对utf8的,否则得先转码下。 查看全部
PHP和JS通讯通常都用json,但用 json 传过来的数组并不是标准的array,而是 stdClass 类型。那么我们可以参考下面的几个方法进行转换。
 
方法一:
//PHP stdClass Object转array  
function object_array($array) {
if(is_object($array)) {
$array = (array)$array;
} if(is_array($array)) {
foreach($array as $key=>$value) {
$array[$key] = object_array($value);
}
}
return $array;
}
方法二:
$array = json_decode(json_encode(simplexml_load_string($xmlString)),TRUE);
方法三:
 function object2array_pre(&$object) {
if (is_object($object)) {
$arr = (array)($object);
} else {
$arr = &$object;
}
if (is_array($arr)) {
foreach($arr as $varName => $varValue){
$arr[$varName] = $this->object2array($varValue);
}
}
return $arr;
}```


如果是10W的数据量的话,执行要进1s,结构再复杂些,可以达到3s, 性能太差了
可以用以下替换:

function object2array(&$object) {

$object = json_decode( json_encode( $object),true);
return $object;
}


但是对json的特性,只能是针对utf8的,否则得先转码下。