php – create_function而不是lambda-function avartaco
发布时间:2020-12-13 18:17:03 所属栏目:PHP教程 来源:网络整理
导读:我试图实现 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 us
我试图实现
avartaco,这就像是gravatar.
为了使它在php版本中工作< 5.3
我收到错误Parse错误:语法错误,同一行中的意外T_FUNCTION array_walk.My php版本是5.2.17< 5.3 那么我应该在该行中进行哪些更改以使其在php版本中工作< 5.3
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,它的工作原理! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |