PHP yaf显示错误提示

PHP yaf显示错误提示

1就是配置文件的那个错误

error_reporting(E_ALL);

2init.php文件的

function yofErrorHandler($errno, $errstr, $errfile, $errline, $sql = ''){
    $errstrs='错误信息'.$errstr.'错误文件'.$errfile.'错误行数'.$errline;
    echo $errstrs;
    recordriji($errstrs);
}

3 error控制器的

<?php

/**
 * Error.php => Catch and show Yaf Error
 */

class ErrorController extends Yaf_Controller_Abstract {

    /** 
     * Show YAF Error 
     * only display errors under DEV, else save error in LOG_FILE
     * @param exception $exception
     * @return void
     */
    public function errorAction($exception){
        $errorstr='php错误:'.$exception->getMessage().'错误文件'.$exception->getFile().'错误行数'.$exception->getLine();
        echo $errorstr;

        recordriji($errorstr);
        exit();
    }
}

php swoole异步处理mysql

php swoole异步处理mysql

//创建websocket服务器对象,监听0.0.0.0:9509端口
//异步测试
$ws = new swoole_websocket_server("0.0.0.0", 9600);

$ws->set(array(
    'worker_num' => 1,
    'max_conn' => 65535,
    /*'daemonize' => true,*/
    'backlog' => 128,
    'task_worker_num' => 1,
));

//监听WebSocket连接打开事件
$ws->on('open', function ($ws, $request) {

});

/* $tag 1 初始化玩家信息 */
//监听WebSocket消息事件
$ws->on('message', function ($ws, $frame) {

});



//定时器要写在WorkerStart这个里面哦
$ws->on('WorkerStart', function ($serv, $worker_id) {
    //投递异步任务
    $data=array('wef'=>'wefe');

    $task_id = $serv->task($data);
    echo "Dispath AsyncTask: id=$task_id\n";

    /*执行其他操作*/
    echo'lalalalalalal';
});

/*通用的执行*/
function commonexecute($sql, $zhanwei = '', $isdebug = 0)
{
    try {
        $stmt = \Db::getStmt($sql);
        if (empty($zhanwei)) {
            $isok=$stmt->execute();
        } else {
            $isok=$stmt->execute($zhanwei);
        }
        if ($isdebug) {
            getrepairsql($sql, $zhanwei);
        }
    } catch (\PDOException $e) {
        $errorstr1='mysql语句错误1:'.$e->getMessage().PHP_EOL;
        $errorstr2='mysql语句错误2:'.$sql.PHP_EOL;
        echo $errorstr1;
        echo'</br>';
        echo $errorstr2;
        file_put_contents(__DIR__.'/error.log', date("Y-m-d H:i:s"). " " . $errorstr1.PHP_EOL, FILE_APPEND | LOCK_EX);
        file_put_contents(__DIR__.'/error.log', date("Y-m-d H:i:s"). " " . $errorstr2.PHP_EOL, FILE_APPEND | LOCK_EX);
        exit();
    }
    return $isok;
}
//处理异步任务
$ws->on('task', function ($serv, $task_id, $from_id, $data) {

    echo "New AsyncTask[id=$task_id]".PHP_EOL;
    var_dump($data);
    $sql='select SLEEP(6)';
    $isok=commonexecute($sql);
    //返回任务执行的结果
    $serv->finish("$data -> OK");

});
//处理异步任务的结果
$ws->on('finish', function ($serv, $task_id, $data) {
    echo "AsyncTask[$task_id] Finish: $data".PHP_EOL;
});


//监听WebSocket连接关闭事件
$ws->on('close', function ($ws, $fd) {
});


$ws->start();

可以看出了执行sleep sql语句时候并有堵塞线程

jquery手指触摸滑动放大图片的方法(比较靠谱的方法)

jquery手指触摸滑动放大图片的方法(比较靠谱的方法)

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>touch.js demo</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script type="text/javascript" src="{$yuming}/touchjs/js/touch.min.js"></script>
    <script type="text/javascript" src="{$yuming}/touchjs/js/cat.touchjs.js"></script>
    <script type="text/javascript" src="{$yuming}/touchjs/js/jquery-1.10.2.min.js"></script>
</head>
<body>
<style>
    .tcpiccontainer{
        width:100%;
        height: 100%;
        position: absolute;
        left:0px;
        top:0px;
        z-index: 999;
        background: #000;
    }
    .tcpiccontainer img{
        width:100%;
        position: absolute;
        margin-top: 11rem;;
    }
</style>
<div class="tcpiccontainer">
    <img id="targetObj" src="http://demo.somethingwhat.com/images/flower1.jpg" />
</div>




    <script type="text/javascript">
        $(function () {
            var $targetObj = $('#targetObj');
            //初始化设置
            cat.touchjs.init($targetObj, function (left, top, scale, rotate) {
                $('#left').text(left);
                $('#top').text(top);
                $('#scale').text(scale);
                $('#rotate').text(rotate);
                $targetObj.css({
                    left: left,
                    top: top,
                    'transform': 'scale(' + scale + ') rotate(' + rotate + 'deg)',
                    '-webkit-transform': 'scale(' + scale + ') rotate(' + rotate + 'deg)'
                });
            });
            //初始化拖动手势(不需要就注释掉)
//            cat.touchjs.drag($targetObj, function (left, top) {
//                $('#left').text(left);
//                $('#top').text(top);
//            });
            //初始化缩放手势(不需要就注释掉)
            cat.touchjs.scale($targetObj, function (scale) {
                $('#scale').text(scale);
            });
            //初始化旋转手势(不需要就注释掉)
//            cat.touchjs.rotate($targetObj, function (rotate) {
//                $('#rotate').text(rotate);
//            });
        });


    </script>
</body>
</html>

//预览地址
http://wxserver.knowway.cn/home/moban/touchujs.html

mysql General error: 1366 Incorrect string value: ‘\xF0\x9F\x91\x8D\xF0\x9F…’ for column ‘dianpumiaoshu’ at row 1 解决方法

mysql General error: 1366 Incorrect string value: ‘\xF0\x9F\x91\x8D\xF0\x9F…’ for column ‘dianpumiaoshu’ at row 1 解决方法

因为传入了emoji表情 曾经考虑过过滤 但是行不通 所以唯一的方法 就是urlencode后存入数据库 读取的时候再urldecode