
session共享主服务器192.168.0.1
yum -y install nfs-utils rpcbind
vi /etc/exports
#增加一行:
/var/www/html/imagepath/ 192.168.0.2(rw,no_root_squash,no_all_squash,sync)
exportfs -r
service rpcbind start
service nfs start
从服务器192.168.0.2
yum -y install nfs-utils rpcbind
mount -t nfs 192.168.0.1:/var/lib/php/session /var/lib/php/session
参考:http://imysql.cn/node/202
Nio大侠提出了session多服务器共享的问题,原文请见PHP 实现多服务器共享 SESSION 数据。其中,有一种方法就是利用NFS来共享session......

当解码的string有BOM头的时候json_decode会解析失败,我们需先去除BOM头。函数如下:
function removeBOM($str = '')
{
if (substr($str, 0,3) == pack("CCC",0xef,0xbb,0xbf)) {
$str = substr($str, 3);
}
return $str;
}
其他方式:
$result = trim($str, "\xEF\xBB\xBF");
print_r(json_decode($str, true));
exit;
$result = @iconv("UTF-8", "GBK//IGNORE", $str);
$result = @iconv("GBK", "UTF-8//IGNORE", $str);
print_r(j......

最近公司在做magento二次开发,需要将我们的工作流系统通过oauth连上magento,所以需要让php支援oauth扩展,在网上搜了下找到解决方法。
oauth官方下载地址:http://pecl.php.net/package/oauth
windows下安装(xampp方法相同):
从http://pecl.php.net/package/oauth/1.2.3/windows下载你对应php版本的oauth
解压将文件夹中php_oauth.dll放入php/ext
更改 php.ini 加载 oauth
extension=php_oauth.dll
重启apache
用phpinfo ()查看是否成功:
成功后信息应该如下:
OAuth
OAuth support
enabled
PLAINTEXT support
enabled
R......

参看:
A*算法
Floyd算法
迪杰斯特拉算法
博文:
http://www.cnblogs.com/dolphin0520/archive/2011/08/27/2155542.html
http://blog.csdn.net/karldoenitz/article/details/8350277
http://bbs.csdn.net/topics/260084619

mysql版
SELECT 2 * 6378.137 * ASIN( SQRT( POW( SIN( PI( ) * ( 114.09576416015625 - 114.1798 ) /360 ) , 2 ) + COS( PI( ) * 114.09576416015625 /180 ) * COS( 114.1798 * PI( ) /180 ) * POW( SIN( PI( ) * ( 22.3932534047735 - 114.1798 ) /360 ) , 2 ) ) ) AS a
FROM dual
php版
function rad($d)
{
return $d * 3.1415926535898 / 180.0;
}
function GetDistance($lat1, $lng1, $lat2, $lng2)
{
$EARTH_RADIUS = 6378.137; //公里
$radLat1 = rad($lat1);
$radLat2 = rad($lat2);
$a = $radLat1 – $ra......