奇淫巧技

  1. 处理html转义之后的图片路径问题
    $str = htmlspecialchars_decode($info['post_content']);
    $str = preg_replace('/()/i',"\${1}/upload/ueditor/\${3}",$str);

------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

get_defined_vars — 返回由所有已定义变量所组成的数组

array get_defined_vars ( void )


简单的查询返回自定义sql
$subQuery= Db('room_img')->alias('i')->field("if(id > 0 ,'1','0')")->where('i.room_id=a.id')->limit(1)->buildSql();
        $sc = " , $subQuery as img_num ";
img_num = 1 or 0

JQ qrcode 生成带logo 说明的二维码

$('.qrcodes').click(function(){
var url = $(this).data('phone');
var name = $(this).data('name');
$('#qrcode').empty()

//二维码宽高
var qrcodewidth = 300;
var qrcodeheight = 300;
//canvas宽高
var canvaswidth = qrcodewidth;
var canvasheight = qrcodeheight + 50;
//logo宽高
var logowidth = 100;
var logoheight = 100;
//文字描述位置
var textleft = qrcodewidth / 2;
var texttop = qrcodeheight + 30;
//logo位置
var logoleft = (qrcodewidth - logowidth) / 2;
var logotop = (qrcodeheight - logoheight) / 2;

var qrcode = $('#qrcode').qrcode({
render : 'canvas',
text : url,
width : qrcodewidth,
height : qrcodeheight,
background : '#ffffff',
foreground : '#000000',
});
var canvas = qrcode.find('canvas').get(0);
var img = new Image();
img.src = canvas.toDataURL('image/png');
img.onload = function() {
canvas.width = canvaswidth;
canvas.height = canvasheight;
var ctx = canvas.getContext('2d');
//设置画布背景
ctx.fillStyle = '#ffffff';
ctx.fillRect(0, 0, canvas.width, canvas.height);
//设置文字样式
ctx.fillStyle = '#000000';
ctx.font = 'bold ' + 20 + 'px Arial';//字号
ctx.textAlign = 'center';
//文字描述
ctx.fillText(name, textleft, texttop);// name 文字描述
//绘制二维码
ctx.drawImage(img, 0, 0);
//设置logo
var logo = new Image(logowidth, logoheight);
logo.src = 'logo.png';//图片链接
logo.onload = function() {
ctx.drawImage(logo, logoleft, logotop, logowidth, logoheight);
}

}



$('#downloadthis').attr('data-name',name);
$('.ascac').show();
})