Php 将变量传递到函数外部的最佳实践
我正在使用管理我的gif图像。我想得到gif每一帧的持续时间。目前我正在使用以下脚本:Php 将变量传递到函数外部的最佳实践,php,git,Php,Git,我正在使用管理我的gif图像。我想得到gif每一帧的持续时间。目前我正在使用以下脚本: $gifStream = new FileStream("myfile.gif"); $gifDecoder = new Decoder($gifStream); Global $gifDurations; $gifDecoder->decode(function (FrameDecodedEvent $event) { global $gifDurations; $gifDurations[
$gifStream = new FileStream("myfile.gif");
$gifDecoder = new Decoder($gifStream);
Global $gifDurations;
$gifDecoder->decode(function (FrameDecodedEvent $event) {
global $gifDurations;
$gifDurations[] = $event->decodedFrame->getDuration();
});
脚本工作正常,输出为:
array(3) { [0]=> int(200) [1]=> int(200) [2]=> int(200) }
但我想知道有没有更好的方法来达到同样的效果?我尝试使用return
,但没有得到结果。或者我只是没有用正确的方式
请让我知道是否有更好的解决方案
还有,我试着用了。它使用起来很简单,但无法获得正确的持续时间。你是想标记
git
吗?使用使用(&$a)
放弃全局想法。a使用
少一些示例:@evolutionxbox哦..是的。对不起,标签弄错了。@lawrencerone谢谢。我要试试这个