php – create_function而不是lambda-function avartaco

我试图实现 avartaco,这就像是gravatar.

为了使它在PHP版本中工作< 5.3

If you want to make it work on PHP less than 5.3.0,find string

array_walk($shape,function(&$coord,$index,$mult) { $coord *= $mult;
},self::SPRITE_SIZE);

and rewrite it for using create_function() instead of lambda-function.

我收到错误Parse错误:语法错误,同一行中的意外T_FUNCTION array_walk.My PHP版本是5.2.17< 5.3
但我不知道createfunction重写是什么意思?

那么我应该在该行中进行哪些更改以使其在PHP版本中工作< 5.3

private function GetShape($type) {

switch($type) {

        case 'side':

            $shape_id = hexdec(substr($this->_hash,22,1)) & (sizeof($this->_shapesSide) - 1);

            $shapes = $this->_shapesSide;
        break;
        case 'center':
            $shape_id = hexdec(substr($this->_hash,23,1)) & (sizeof($this->_shapesCenter) - 1);

            $shapes = $this->_shapesCenter;
        break;

        case 'corner':
            $shape_id = hexdec(substr($this->_hash,24,1)) & (sizeof($this->_shapesCorner) - 1);

            $shapes = $this->_shapesCorner;
        default:
        break;

    }

    $shape = $shapes[$shape_id];

    array_walk($shape,$mult) { $coord *= $mult; },self::SPRITE_SIZE);
    return $shape;

}
只需执行以下操作
array_walk(
    $shape,create_function(
        '&$coord,$mult','$coord *= $mult;'
    ),self::SPRITE_SIZE
);

我在PHP<测试了avatarico 5.3,它的工作原理!

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...