源码:特别适用于微信支付中通知微信支付网关
function array2xml($arr, $level = 1) {
$s = $level == 1 ? "<xml>" : '';
foreach ($arr as $tagname => $value) {
//元素为数组或者不为数组的处理
if (!is_array($value)) {
$s .= "<{$tagname}>" . (!is_numeric($value) ? '<![CDATA[' : '') . $value . (!is_numeric($value) ? ']]>' : '') . "</{$tagname}>";
} else {
$s .= "<{$tagname}>" . array2xml($value, $level + 1) . "</{$tagname}>";
}
}
//过滤不合法的字符串
$s = preg_replace("/([\x01-\x08\x0b-\x0c\x0e-\x1f])+/", ' ', $s);
return $level == 1 ? $s . "</xml>" : $s;
}
//微信支付通知后告诉微信网关,我收到了!
$data=array(
'return_code'=>'SUCCESS',
'return_msg' =>'OK',
);
$xmlstr=array2xml($data); <?php $base64_body = substr(strstr($_POST[base64],','),1); $data= base64_decode($base64_body); file_put_contents($_SERVER[&q...
md5/sha1+salt方式是目前各大cms常用的加密方式,虽然salt安全,但是各大md5网站也在研究这个方向,那么我们应该选择password_hash动态hash来助力,一种密码有多种hash结果.看代码模拟登陆.<?php //01.注册 $user ='zhang...
(1).config.php 配置文件<?php /** * RabbitMQ_Config */ $config = [ 'host' => ...
php7新增的特性(1).强制限制只能返回一种类型<?php class task { } //must return an integer function add(): int { &nb...
elasticsearch的操作都是基于http协议的,已经有现成的php类库,composer安装即可。{ "require": { &...
众所周知MyISAM引擎不支持事务,但是我只是知道不支持事务,并未测试具体的表现是什么,测试代码如下:try { //开启事务 Db::startTrans(); &...